From 4beac319f8fbecbc6fac004816738436d2cb7191 Mon Sep 17 00:00:00 2001 From: odan Date: Thu, 18 Jul 2019 23:00:40 +0200 Subject: [PATCH 01/10] Update readme (cherry picked from commit 85b7603eeff28e3cc07ad8b0b17dfe0176bfc78b) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 667994c..9b345e6 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ Register middleware for a routing group: // config/routes.php use League\Route\Router; +use League\Route\RouteGroup; use Odan\Session\SessionMiddleware; $router = $container->get(Router::class); From 0585641e07bc1ef756d1114d05b8053567d9b7d0 Mon Sep 17 00:00:00 2001 From: odan Date: Sun, 23 Feb 2020 20:25:47 +0100 Subject: [PATCH 02/10] Update readme (cherry picked from commit 190408346a06f1657bbacb742b1453f18c5d95fb) --- README.md | 94 +++++++++++++++++++++---------------------------------- 1 file changed, 36 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 9b345e6..6126944 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A session handler for PHP [![Build Status](https://travis-ci.org/odan/session.svg?branch=master)](https://travis-ci.org/odan/session) [![Code Coverage](https://scrutinizer-ci.com/g/odan/session/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/odan/session/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/odan/session/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/odan/session/?branch=master) -[![Total Downloads](https://img.shields.io/packagist/dt/odan/session.svg)](https://packagist.org/packages/odan/session) +[![Total Downloads](https://img.shields.io/packagist/dt/odan/session.svg)](https://packagist.org/packages/odan/session/status) ## Requirements @@ -155,14 +155,15 @@ $session = new MemorySession(); #### Configuration -Add your application-specific settings. - -In this example we store all settings in a PHP file. +Add your application-specific settings: ```php // config/settings.php return [ + + // ... + 'session' => [ 'name' => 'webapp', 'cache_expire' => 0, @@ -172,90 +173,62 @@ return [ ]; ``` -For this example we use the [leage/container](https://github.com/thephpleague/container) package. +For this example we use the [PHP-DI](http://php-di.org/) package. -Add the PSR-15 middleware factory: +Add the container definitions as follows: ```php -// config/container.php - -use League\Container\Container; -use League\Container\ReflectionContainer; +use Odan\Session\PhpSession; use Odan\Session\SessionInterface; use Odan\Session\SessionMiddleware; +use Psr\Container\ContainerInterface; -$container = new Container(); - -$container->delegate(new ReflectionContainer()); +return [ + // ... -$container->share('settings', static function () { - return require __DIR__ . '/settings.php'; -}); + SessionInterface::class => function (ContainerInterface $container) { + $settings = $container->get('settings'); + $session = new PhpSession(); + $session->setOptions((array)$settings['session']); -$container->share(SessionInterface::class, static function (Container $container) { - $settings = $container->get('settings'); - $session = new PhpSession(); - $session->setOptions((array)$settings['session']); + return $session; + }, - return $session; -})->addArgument($container); - -$container->share(SessionMiddleware::class, static function (Container $container) { - return new SessionMiddleware($container->get(SessionInterface::class)); -})->addArgument($container); + SessionMiddleware::class => function (ContainerInterface $container) { + return new SessionMiddleware($container->get(SessionInterface::class)); + }, +]; ``` ##### Registering middleware routes -For this example we use the [league/route](https://github.com/thephpleague/container) package. - Register middleware for all routes: ```php -// config/middleware.php - -use League\Route\Router; use Odan\Session\SessionMiddleware; -$router = $container->get(Router::class); - -$router->lazyMiddleware(SessionMiddleware::class); - -return $router; +$app->add(SessionMiddleware::class); ``` Register middleware for a routing group: ```php -// config/routes.php - -use League\Route\Router; -use League\Route\RouteGroup; use Odan\Session\SessionMiddleware; +use Slim\Routing\RouteCollectorProxy; -$router = $container->get(Router::class); - -$router->group('/users', static function (RouteGroup $group): void { - $group->post('/login', \App\Action\UserLoginSubmitAction::class); -})->lazyMiddleware(SessionMiddleware::class); - -return $router; +// Protect the whole group +$app->group('/admin', function (RouteCollectorProxy $group) { + // ... +})->add(SessionMiddleware::class); ``` Register middleware for a single route: ```php -// config/routes.php - -use League\Route\Router; use Odan\Session\SessionMiddleware; -$router = $container->get(Router::class); - -$router->get('/users', \App\Action\HomeIndexAction::class) - ->lazyMiddleware(SessionMiddleware::class); - -return $router; +$app->post('/example', \App\Action\ExampleAction::class) + ->add(SessionMiddleware::class); ``` ### Slim 3 framework integration @@ -281,7 +254,6 @@ Add the session factory: ```php use Odan\Session\PhpSession; use Odan\Session\SessionInterface; -use Odan\Session\SessionMiddleware; use Psr\Container\ContainerInterface as Container; $container[SessionInterface::class] = function (Container $container) { @@ -336,5 +308,11 @@ $app->group('/users', function () { ## Similar packages -* https://symfony.com/doc/current/components/http_foundation/sessions.html +* https://github.com/laminas/laminas-session * https://github.com/auraphp/Aura.Session +* https://github.com/rakit/session +* https://symfony.com/doc/current/components/http_foundation/sessions.html + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. From b724da9b1860f718facaa1732ceb4c451b8a2c98 Mon Sep 17 00:00:00 2001 From: odan Date: Sun, 23 Feb 2020 20:35:36 +0100 Subject: [PATCH 03/10] Update readme (cherry picked from commit 6164afbcb14e4c57d16b95449bd03fd7074e1772) --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 6126944..a0d2418 100644 --- a/README.md +++ b/README.md @@ -309,8 +309,6 @@ $app->group('/users', function () { ## Similar packages * https://github.com/laminas/laminas-session -* https://github.com/auraphp/Aura.Session -* https://github.com/rakit/session * https://symfony.com/doc/current/components/http_foundation/sessions.html ## License From d3bc7bed4d20aead540506555de7b6a1fe8c7840 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Mon, 24 Feb 2020 11:45:20 +0100 Subject: [PATCH 04/10] Update README.md (cherry picked from commit 96bc01132242e3d8e0f56919e4d66157a1b69de5) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a0d2418..ff87b76 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,8 @@ For this example we use the [PHP-DI](http://php-di.org/) package. Add the container definitions as follows: ```php + Date: Sun, 8 Mar 2020 14:46:26 +0100 Subject: [PATCH 05/10] Update link (cherry picked from commit fae87f2147e72905f6f2d7e66a08cf0258d5e411) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff87b76..719fa1c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A session handler for PHP [![Build Status](https://travis-ci.org/odan/session.svg?branch=master)](https://travis-ci.org/odan/session) [![Code Coverage](https://scrutinizer-ci.com/g/odan/session/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/odan/session/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/odan/session/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/odan/session/?branch=master) -[![Total Downloads](https://img.shields.io/packagist/dt/odan/session.svg)](https://packagist.org/packages/odan/session/status) +[![Total Downloads](https://img.shields.io/packagist/dt/odan/session.svg)](https://packagist.org/packages/odan/session/stats) ## Requirements From 8737c55e06190cf32d8d9384d80f53026318f38f Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Sat, 28 Mar 2020 12:17:14 +0100 Subject: [PATCH 06/10] Update README.md (cherry picked from commit e299ad7c8d18fec850c2c1016018824fa3a506d1) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 719fa1c..a5c822b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ composer require odan/session ```php use Odan\Session\PhpSession; -// Set session options before we start +// Set session options before you start the session // You can use all the standard PHP session configuration options // https://secure.php.net/manual/en/session.configuration.php From 47a3fd324350a25a954080b18dd3a33e9c551095 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Sat, 28 Mar 2020 12:19:40 +0100 Subject: [PATCH 07/10] Update README.md (cherry picked from commit 3b2c52ea829943224557680ec0020718880973e7) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5c822b..fe94116 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ $session->clear(); // Generate a new session ID $session->regenerateId(); -// Clears all session data and regenerates session ID +// Clears all session $session->destroy(); // Get the current session ID From 292be4843e772cd938db83ba9c376ca64b2984bb Mon Sep 17 00:00:00 2001 From: odan Date: Wed, 23 Dec 2020 18:46:51 +0100 Subject: [PATCH 08/10] Update year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 30d7b83..fa19b85 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 odan +Copyright (c) 2021 odan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 47fd447eb6bc6fc59e8608d6c3c53738483966cf Mon Sep 17 00:00:00 2001 From: odan Date: Wed, 23 Dec 2020 18:48:01 +0100 Subject: [PATCH 09/10] Remove travis build --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 88ee7cf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - -dist: xenial - -cache: - directories: - - $HOME/.composer/cache - -before_script: - - composer self-update - - composer update --no-interaction --prefer-dist --no-progress - - cd $TRAVIS_BUILD_DIR - -script: - - composer check-all From c35000f65b058c1f7c9660c6f33ba26f7a8c3000 Mon Sep 17 00:00:00 2001 From: odan Date: Wed, 23 Dec 2020 18:49:00 +0100 Subject: [PATCH 10/10] Add PHP 8.0 support #14 --- README.md | 2 +- composer.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fe94116..b2e277c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A session handler for PHP ## Requirements -* PHP 7.2+ +* PHP 7.2+ or 8.0+ ## Installation diff --git a/composer.json b/composer.json index 572b66a..1be9b35 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "psr/http-message": "^1.0", "psr/http-server-handler": "^1.0", "psr/http-server-middleware": "^1.0" @@ -23,7 +23,7 @@ "require-dev": { "overtrue/phplint": "^1.1", "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^8.0", + "phpunit/phpunit": "^8.0 || ^9.0", "slim/slim": "^3.12", "squizlabs/php_codesniffer": "^3.4" },