ray / aura-session-module
Aura Session module for Ray.Di
Installs: 36 238
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 1
Requires
- php: ^7.2 || ^8.0
- aura/session: ^2.1
- ircmaxell/random-lib: ^1.1
- ray/di: ^2.5.3
Requires (Dev)
- phpunit/phpunit: ^8.5.29
This package is auto-updated.
Last update: 2024-12-16 04:09:21 UTC
README
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' } }