damess / expressive-session-middleware
Simple session middleware for Zend Expressive
Installs: 12 086
Dependents: 1
Suggesters: 0
Security: 0
Stars: 10
Watchers: 2
Forks: 8
Open Issues: 0
Requires
- php: >=5.5.0
- aura/session: ^2.0
- container-interop/container-interop: ^1.1
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ^2.3
- zendframework/zend-diactoros: ^1.1
This package is not auto-updated.
Last update: 2024-11-20 23:19:12 UTC
README
Simple session middleware for Zend Expressive
Install
Via Composer
$ composer require damess/expressive-session-middleware
Usage
Add the following factories to your container config
return [ 'dependencies' => [ 'factories' => [ DaMess\Http\SessionMiddleware::class => DaMess\Factory\SessionMiddlewareFactory::class, Aura\Session\Session::class => DaMess\Factory\AuraSessionFactory::class, ], ], ];
Set up the pre-routing middleware.
return [ 'middleware_pipeline' => [ 'always' => [ 'middleware' => [ DaMess\Http\SessionMiddleware::class, ], 'priority' => 10000, ], ], ];
Get the session object from the request
/** * @param ServerRequestInterface $request * @param ResponseInterface $response * @return ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response) { /** * @var \Aura\Session\Session $session */ $session = $request->getAttribute(\DaMess\Http\SessionMiddleware::KEY); }
Configuration
The session can be configured by adding the following data to your configuration i.e. session.global.php. See session.global.php.dist
return [ 'session' => [ 'name' => 'PHPSESSID', 'lifetime' => 7200, 'path' => null, 'domain' => null, 'secure' => false, 'httponly' => true, ], ];
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
License
The MIT License (MIT). Please see License File for more information.