Giter Club home page Giter Club logo

rese's Introduction

Readable Session Helper

Write your php sessions in a more readable way. Great for multidimensional sessions.

Extracted from vume framework.

Get started

Check the example file.

Requirements
  • PHP 5.3+
  • Composer
Install

The easiest way to install Rese is via Composer. Add this to your composer.json file and run $ composer update:

{
  "require": {
    "devfake/rese": "dev-master"
  }
}

Create a helper function (if you like):

function session($keys = null)
{
  return new Devfake\Rese\Session($keys, '.');
}

Working with the new helper:

// $_SESSION
session()->get();

// $_SESSION['key'];
session('key')->get();

// $_SESSION['key']['more']['deep'];
session('key.more.deep')->get();

// Pass a default value into get() if the key not exists:
session('not.available')->get('my default value');

// $_SESSION['key']['more'] = $data;
session('key.more')->set($data);

// isset($_SESSION['key']);
session('key')->exists();

// Send a flash message:
session('input.error')->message();

// $_SESSION['key'] == 'value';
session('key')->is('value');

// unset($_SESSION['key']['and']['more']['deeply']);
session('key.and.more.deeply')->remove();
// Alias for remove():
session('key.and.more.deeply')->delete();

// Destroy complete session:
session()->destroy();

You can change the separation by add a second argument for the class call in the helper function. Change to whatever you like (e.g '->' or '/'):

session('key->and->other')->get();
session('key/and/other')->get();

rese's People

Contributors

devfake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.