{"id":20103175,"url":"https://github.com/dotkernel/dot-response-header","last_synced_at":"2025-05-06T08:31:12.035Z","repository":{"id":42436748,"uuid":"364202202","full_name":"dotkernel/dot-response-header","owner":"dotkernel","description":"Configuration of all Response Headers","archived":false,"fork":false,"pushed_at":"2025-03-12T08:12:40.000Z","size":95,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"3.0","last_synced_at":"2025-04-15T01:03:01.578Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.dotkernel.org/dot-response-header/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotkernel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-04T09:19:20.000Z","updated_at":"2025-03-12T08:06:10.000Z","dependencies_parsed_at":"2024-05-08T10:41:03.652Z","dependency_job_id":null,"html_url":"https://github.com/dotkernel/dot-response-header","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.5,"last_synced_commit":"919bc505a5888ad90548f23b711bf98a1c00cb86"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-response-header","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-response-header/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-response-header/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-response-header/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotkernel","download_url":"https://codeload.github.com/dotkernel/dot-response-header/tar.gz/refs/heads/3.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252648575,"owners_count":21782405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T17:34:34.788Z","updated_at":"2025-05-06T08:31:12.029Z","avatar_url":"https://github.com/dotkernel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dot-response-header\n\n`dot-response-header` is Dotkernel's middleware for setting and overwriting custom response headers.\n\n## Documentation\n\nDocumentation is available at: https://docs.dotkernel.org/dot-response-header/.\n\n## Badges\n\n![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-response-header)\n![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-response-header/3.5.0)\n\n[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/issues)\n[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/network)\n[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/stargazers)\n[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-response-header)](https://github.com/dotkernel/dot-response-header/blob/3.0/LICENSE)\n\n[![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)\n[![codecov](https://codecov.io/gh/dotkernel/dot-response-header/graph/badge.svg?token=NNRZN0FBF2)](https://codecov.io/gh/dotkernel/dot-response-header)\n[![PHPStan](https://github.com/dotkernel/dot-response-header/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-response-header/actions/workflows/static-analysis.yml)\n\n## Requirements\n\n- **PHP**: 8.1, 8.2, 8.3 or 8.4\n\n## Installation\n\nRun the following command in your project root directory:\n\n```shell\ncomposer require dotkernel/dot-response-header\n```\n\nNext, register the package's `ConfigProvider` to your application config.\n\n```php\nDot\\ResponseHeader\\ConfigProvider::class,\n```\n\n\u003e Make sure to register the package under the `// DK packages` section.\n\nAfter registering the package, add it to the middleware stack in `config/pipeline.php` after `$app-\u003epipe(RouteMiddleware::class);`\n\n```php\n$app-\u003epipe(RouteMiddleware::class);\n$app-\u003epipe(\\Dot\\ResponseHeader\\Middleware\\ResponseHeaderMiddleware::class);\n```\n\nCreate a new file `response-header.global.php` in `config/autoload` with the below configuration array:\n\n```php\n\u003c?php\n    return [\n        'dot_response_headers' =\u003e [\n            '*' =\u003e [\n                'CustomHeader1' =\u003e [\n                    'value' =\u003e 'CustomHeader1-Value',\n                    'overwrite' =\u003e true,\n                ],\n                'CustomHeader2' =\u003e [\n                    'value' =\u003e 'CustomHeader2-Value',\n                    'overwrite' =\u003e false,\n                ],\n            ],\n            'home' =\u003e [\n                'CustomHeader' =\u003e [\n                    'value' =\u003e 'header3',\n                ]\n            ],\n            'login' =\u003e [\n                'LoginHeader' =\u003e [\n                    'value' =\u003e 'LoginHeader-Value',\n                    'overwrite' =\u003e false\n                ]\n            ],\n        ]\n    ];\n```\n\nBecause headers are matched with route names, we can have custom response headers for every request, by defining new headers under the `*` key.\n\nAll headers under `*` will be set for every response.\n\nTo add response headers for a specific set of routes, define a new array using the route name as the array key.\n\nExample:\n\n```php\n'dot_response_headers' =\u003e [\n    'user' =\u003e [\n        'UserCustomHeader' =\u003e [\n            'value' =\u003e 'UserCustomHeader-Value',\n            'overwrite' =\u003e false\n        ]\n    ],\n]\n\n// This will set a new header named UserCustomHeader with the UserCustomHeader-Value value for any route name matching 'user'\n```\n\nTo overwrite an existing header use `overwrite =\u003e true`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-response-header","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotkernel%2Fdot-response-header","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-response-header/lists"}