Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 1.25 KB

README.md

File metadata and controls

54 lines (38 loc) · 1.25 KB

Ray.AuraSessionModule

Continuous Integration

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(): void
    {
        $this->install(new AuraSessionModule);
    }
}

Usage

use Aura\Session\Session;
use MyVendor\MyPackage\MyClass;

class Index extends ResourceObject
{
    public function __construct(
        private readonly Session $session
    ) {}
    
    public function onGet() : static
    {
        // get a _Segment_ object
        $segment = $this->session->getSegment(MyClass::class);
        
        // 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'
    }
}