File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,12 +14,12 @@ jobs:
1414 strategy :
1515 matrix :
1616 operating-system : [ ubuntu-latest ]
17- php-versions : [ '8.2', '8.3', '8.4' ]
17+ php-versions : [ '8.2', '8.3', '8.4', '8.5' ]
1818 name : PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
1919
2020 steps :
2121 - name : Checkout
22- uses : actions/checkout@v1
22+ uses : actions/checkout@v5
2323
2424 - name : Setup PHP
2525 uses : shivammathur/setup-php@v2
4848 run : composer stan
4949
5050 - name : Run tests
51- if : ${{ matrix.php-versions != '8.4 ' }}
51+ if : ${{ matrix.php-versions != '8.5 ' }}
5252 run : composer test
5353
5454 - name : Run tests with coverage
55- if : ${{ matrix.php-versions == '8.4 ' }}
55+ if : ${{ matrix.php-versions == '8.5 ' }}
5656 run : composer test:coverage
Original file line number Diff line number Diff line change 99 ],
1010 "homepage" : " https://github.com/odan/session" ,
1111 "require" : {
12- "php" : " ~8.2.0 || ~8.3.0 || ~8.4.0" ,
12+ "php" : " ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 " ,
1313 "psr/http-message" : " ^1 || ^2" ,
1414 "psr/http-server-handler" : " ^1" ,
1515 "psr/http-server-middleware" : " ^1"
Original file line number Diff line number Diff line change @@ -264,6 +264,49 @@ return [
264264];
265265```
266266
267+ ### Single action controller usage
268+
269+ Depending on the use case, define ` Odan\Session\SessionInterface ` or/and ` Odan\Session\SessionManagerInterface `
270+ within the class constructor.
271+
272+ ** Example:**
273+
274+ ``` php
275+ <?php
276+
277+ namespace App\Action;
278+
279+ use Odan\Session\SessionInterface;
280+ use Psr\Http\Message\ResponseInterface;
281+ use Psr\Http\Message\ServerRequestInterface;
282+
283+ final class HomeAction
284+ {
285+ private SessionInterface $session;
286+
287+ public function __construct(SessionInterface $session)
288+ {
289+ $this->session = $session;
290+ }
291+
292+ public function __invoke(
293+ ServerRequestInterface $request,
294+ ResponseInterface $response
295+ ): ResponseInterface {
296+ // Store a value in session
297+ $this->session->set('message', 'Hello from session');
298+
299+ // or read value from session
300+ $message = $this->session->get('message');
301+
302+ $response->getBody()->write($message);
303+
304+ return $response;
305+ }
306+ }
307+ ```
308+
309+
267310### Session middleware
268311
269312** Lazy session start**
You can’t perform that action at this time.
0 commit comments