|
| 1 | +# middlewares/aura-session |
| 2 | + |
| 3 | +[![Latest Version on Packagist][ico-version]][link-packagist] |
| 4 | +[![Software License][ico-license]](LICENSE.md) |
| 5 | +[![Build Status][ico-travis]][link-travis] |
| 6 | +[![Quality Score][ico-scrutinizer]][link-scrutinizer] |
| 7 | +[![Total Downloads][ico-downloads]][link-downloads] |
| 8 | +[![SensioLabs Insight][ico-sensiolabs]][link-sensiolabs] |
| 9 | + |
| 10 | +Middleware to manage sessions using [Aura.Session](https://github.com/auraphp/Aura.Session). |
| 11 | + |
| 12 | +**Note:** This middleware is intended for server side only |
| 13 | + |
| 14 | +## Requirements |
| 15 | + |
| 16 | +* PHP >= 5.6 |
| 17 | +* A [PSR-7](https://packagist.org/providers/psr/http-message-implementation) http mesage implementation ([Diactoros](https://github.com/zendframework/zend-diactoros), [Guzzle](https://github.com/guzzle/psr7), [Slim](https://github.com/slimphp/Slim), etc...) |
| 18 | +* A [PSR-15](https://github.com/http-interop/http-middleware) middleware dispatcher ([Middleman](https://github.com/mindplay-dk/middleman), etc...) |
| 19 | + |
| 20 | +## Installation |
| 21 | + |
| 22 | +This package is installable and autoloadable via Composer as [middlewares/aura-session](https://packagist.org/packages/middlewares/aura-session). |
| 23 | + |
| 24 | +```sh |
| 25 | +composer require middlewares/aura-session |
| 26 | +``` |
| 27 | + |
| 28 | +## Example |
| 29 | + |
| 30 | +```php |
| 31 | +$dispatcher = new Dispatcher([ |
| 32 | + new Middlewares\AuraSession(), |
| 33 | + |
| 34 | + function ($request) { |
| 35 | + //get the session object |
| 36 | + $session = $request->getAttribute('session'); |
| 37 | + } |
| 38 | +]); |
| 39 | + |
| 40 | +$response = $dispatcher->dispatch(new ServerRequest()); |
| 41 | +``` |
| 42 | + |
| 43 | +## Options |
| 44 | + |
| 45 | +#### `__construct(Aura\Session\SessionFactory $factory = null)` |
| 46 | + |
| 47 | +To use a custom session factory. If it's not passed, it will be created automatically. |
| 48 | + |
| 49 | +#### `name(string $name)` |
| 50 | + |
| 51 | +The session name. If it's not defined, the default `PHPSESSID` will be used. |
| 52 | + |
| 53 | +#### `attribute(string $attribute)` |
| 54 | + |
| 55 | +The attribute name used to store the session in the session request. By default is `session`. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details. |
| 60 | + |
| 61 | +The MIT License (MIT). Please see [LICENSE](LICENSE) for more information. |
| 62 | + |
| 63 | +[ico-version]: https://img.shields.io/packagist/v/middlewares/aura-session.svg?style=flat-square |
| 64 | +[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square |
| 65 | +[ico-travis]: https://img.shields.io/travis/middlewares/aura-session/master.svg?style=flat-square |
| 66 | +[ico-scrutinizer]: https://img.shields.io/scrutinizer/g/middlewares/aura-session.svg?style=flat-square |
| 67 | +[ico-downloads]: https://img.shields.io/packagist/dt/middlewares/aura-session.svg?style=flat-square |
| 68 | +[ico-sensiolabs]: https://img.shields.io/sensiolabs/i/36786f5a-2a15-4399-8817-8f24fcd8c0b4.svg?style=flat-square |
| 69 | + |
| 70 | +[link-packagist]: https://packagist.org/packages/middlewares/aura-session |
| 71 | +[link-travis]: https://travis-ci.org/middlewares/aura-session |
| 72 | +[link-scrutinizer]: https://scrutinizer-ci.com/g/middlewares/aura-session |
| 73 | +[link-downloads]: https://packagist.org/packages/middlewares/aura-session |
| 74 | +[link-sensiolabs]: https://insight.sensiolabs.com/projects/36786f5a-2a15-4399-8817-8f24fcd8c0b4 |
0 commit comments