ray/aura-session-module

Aura Session module for Ray.Di

1.1.0 2016-09-05 16:58 UTC

This package is auto-updated.

Last update: 2020-10-06 22:35:27 UTC


README

Scrutinizer Code Quality Code Coverage Build Status Build Status

An Aura.Session module for Ray.Di.

Installation

Composer install

$ composer require ray/aura-session-module

Module install

use Ray\Di\AbstractModule;
use Ray\AuraSessionModule\AuraSessionModule;

class AppModule extends AbstractModule
{
    protected function configure()
    {
        $this->install(new AuraSessionModule);
    }
}

Usage

use Ray\AuraSessionModule\AuraSessionInject;

class Index extends ResourceObject
{
    use AuraSessionInject;
    
    public function onGet() : ResourceObject
    {
        // get a _Segment_ object
        $segment = $this->session->getSegment('Vendor\Package\ClassName');
        
        // try to get a value from the segment;
        // if it does not exist, return an alternative value
        echo $segment->get('foo'); // null
        echo $segment->get('baz', 'not set'); // 'not set'
    }
}

See more about Aura.Session.