diff --git a/app/src/Bootstrap/AppManager.php b/app/src/Bootstrap/AppManager.php index 983f741..e68fa8e 100644 --- a/app/src/Bootstrap/AppManager.php +++ b/app/src/Bootstrap/AppManager.php @@ -6,6 +6,7 @@ use App\Providers; use DI\Bridge\Slim\Bridge; use DI\Container; use Invoker\CallableResolver; +use Middlewares; use Slim\App; use Tightenco\Collect\Support\Collection; @@ -43,8 +44,10 @@ class AppManager public function __invoke(): App { $this->registerProviders(); + $app = Bridge::create($this->container); + $app->add(new Middlewares\Expires(['text/json' => '+1 hour'])); - return Bridge::create($this->container); + return $app; } /** @@ -55,7 +58,7 @@ class AppManager protected function registerProviders(): void { Collection::make(self::PROVIDERS)->each( - function (string $provider) { + function (string $provider): void { $this->container->call( $this->callableResolver->resolve($provider) ); diff --git a/composer.json b/composer.json index 43d5901..e412232 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "require": { "php": ">=7.2", "erusev/parsedown-extra": "^0.8.1", + "middlewares/cache": "^2.0", "phlak/config": "^6.1", "php-di/php-di": "^6.0", "php-di/slim-bridge": "^3.0", diff --git a/composer.lock b/composer.lock index 44f0d41..78681d5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1b0549fc40f9a31f80ef948fcc2e5eda", + "content-hash": "9768cdbffec8cc009ab0930f4da7c781", "packages": [ { "name": "erusev/parsedown", @@ -209,6 +209,160 @@ ], "time": "2018-03-21T22:21:57+00:00" }, + { + "name": "micheh/psr7-cache", + "version": "0.5", + "source": { + "type": "git", + "url": "https://github.com/micheh/psr7-cache.git", + "reference": "b99e8ae6d024d8c70945084b5b979a62cfd05df4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/micheh/psr7-cache/zipball/b99e8ae6d024d8c70945084b5b979a62cfd05df4", + "reference": "b99e8ae6d024d8c70945084b5b979a62cfd05df4", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0||~5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Micheh\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Cache and conditional request helpers for PSR-7 HTTP Messages", + "keywords": [ + "cache", + "conditional", + "http", + "http-message", + "if-match", + "if-modified-since", + "if-none-match", + "if-unmodified-since", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-04-15T16:31:14+00:00" + }, + { + "name": "middlewares/cache", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/middlewares/cache.git", + "reference": "75090ac75abdfd0756c07eef18cd002f5faf0fc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/middlewares/cache/zipball/75090ac75abdfd0756c07eef18cd002f5faf0fc0", + "reference": "75090ac75abdfd0756c07eef18cd002f5faf0fc0", + "shasum": "" + }, + "require": { + "micheh/psr7-cache": "^0.5.0", + "middlewares/utils": "^3.0", + "php": "^7.2", + "psr/cache": "^1.0", + "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "matthiasmullie/scrapbook": "^1.4", + "oscarotero/php-cs-fixer-config": "^1.0", + "phpunit/phpunit": "^8.1", + "squizlabs/php_codesniffer": "^3.0", + "zendframework/zend-diactoros": "^2.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Middlewares\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Middleware with various cache utilities", + "homepage": "https://github.com/middlewares/cache", + "keywords": [ + "http", + "middleware", + "psr-15", + "psr-7" + ], + "time": "2019-12-01T00:39:05+00:00" + }, + { + "name": "middlewares/utils", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/middlewares/utils.git", + "reference": "13689487e8f3bba10b6cc66ed206efc8b874163e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/middlewares/utils/zipball/13689487e8f3bba10b6cc66ed206efc8b874163e", + "reference": "13689487e8f3bba10b6cc66ed206efc8b874163e", + "shasum": "" + }, + "require": { + "php": "^7.2", + "psr/container": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "guzzlehttp/psr7": "dev-master", + "laminas/laminas-diactoros": "^2.2", + "nyholm/psr7": "^1.0", + "oscarotero/php-cs-fixer-config": "^1.0", + "phpunit/phpunit": "^8.1", + "slim/psr7": "~0.3", + "squizlabs/php_codesniffer": "^3.0", + "sunrise/http-message": "^1.0", + "sunrise/http-server-request": "^1.0", + "sunrise/stream": "^1.0", + "sunrise/uri": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Middlewares\\Utils\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Common utils for PSR-15 middleware packages", + "homepage": "https://github.com/middlewares/utils", + "keywords": [ + "PSR-11", + "http", + "middleware", + "psr-15", + "psr-17", + "psr-7" + ], + "time": "2020-01-19T00:30:41+00:00" + }, { "name": "nikic/fast-route", "version": "v1.3.0", @@ -586,6 +740,52 @@ ], "time": "2019-12-15T19:35:24+00:00" }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "time": "2016-08-06T20:24:11+00:00" + }, { "name": "psr/container", "version": "1.0.0",