diff --git a/README.md b/README.md index ca61a51..d18cbeb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # dot-response-header ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-response-header) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-response-header/3.2.3) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-response-header/3.4.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/network) @@ -11,8 +11,6 @@ [![Build Static](https://github.com/dotkernel/dot-response-header/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-response-header/actions/workflows/continuous-integration.yml) [![codecov](https://codecov.io/gh/dotkernel/dot-response-header/graph/badge.svg?token=NNRZN0FBF2)](https://codecov.io/gh/dotkernel/dot-response-header) -[![SymfonyInsight](https://insight.symfony.com/projects/dce88959-bd29-40ef-b1e7-d12815145438/big.svg)](https://insight.symfony.com/projects/dce88959-bd29-40ef-b1e7-d12815145438) - Middleware for setting and overwriting custom response headers. ## Requirements @@ -23,22 +21,29 @@ Middleware for setting and overwriting custom response headers. Run the following command in your project root directory - composer require dotkernel/dot-response-header +```shell +composer require dotkernel/dot-response-header +``` Next, register the package's `ConfigProvider` to your application config. - Dot\ResponseHeader\ConfigProvider::class, +```php +Dot\ResponseHeader\ConfigProvider::class, +``` -Note : Make sure to register the package under the `// DK packages` section. +Note: Make sure to register the package under the `// DK packages` section. After registering the package, add it to the middleware stack in `config/pipeline.php` after `$app->pipe(RouteMiddleware::class);` - $app->pipe(RouteMiddleware::class); - $app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); +```php +$app->pipe(RouteMiddleware::class); +$app->pipe(\Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware::class); +``` -Create a new file `response-header.global.php` in `config/autoload` with the below configuration array : +Create a new file `response-header.global.php` in `config/autoload` with the below configuration array: - [ '*' => [ @@ -63,7 +68,8 @@ Create a new file `response-header.global.php` in `config/autoload` with the bel ] ], ] - ]; + ]; +``` Because headers are matched with route names, we can have custom response headers for every request, by defining new headers under the `*` key. @@ -71,17 +77,19 @@ All headers under `*` will be set for every response. To add response headers for a specific set of routes, define a new array using the route name as the array key. -Example : - - 'dot_response_headers' => [ - 'user' => [ - 'UserCustomHeader' => [ - 'value' => 'UserCustomHeader-Value', - 'overwrite' => false - ] - ], - ] - - // This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' +Example: + +```php +'dot_response_headers' => [ + 'user' => [ + 'UserCustomHeader' => [ + 'value' => 'UserCustomHeader-Value', + 'overwrite' => false + ] + ], +] + +// This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user' +``` To overwrite an existing header use `overwrite => true`. diff --git a/composer.json b/composer.json index 5d109d8..d657b16 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "mezzio" ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "mezzio/mezzio-router": "^3.16", "psr/http-client": "^1.0", "psr/http-message": "^1.0 || ^2.0" diff --git a/docs/book/index.md b/docs/book/index.md deleted file mode 100644 index ae42a26..0000000 --- a/docs/book/index.md +++ /dev/null @@ -1 +0,0 @@ -../../README.md diff --git a/docs/book/index.md b/docs/book/index.md new file mode 120000 index 0000000..fe84005 --- /dev/null +++ b/docs/book/index.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file