PHPackages                             republique-et-canton-de-geneve/response-headers-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. republique-et-canton-de-geneve/response-headers-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

republique-et-canton-de-geneve/response-headers-bundle
======================================================

A Symfony bundle to easily send headers in your HTTP response

1.0.4(4mo ago)11031Apache-2.0PHPPHP &gt;=8.1CI passing

Since Dec 27Pushed 4mo agoCompare

[ Source](https://github.com/republique-et-canton-de-geneve/response-headers-bundle)[ Packagist](https://packagist.org/packages/republique-et-canton-de-geneve/response-headers-bundle)[ RSS](/packages/republique-et-canton-de-geneve-response-headers-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (5)Used By (0)

A Symfony bundle to add headers to your HTTP response.
======================================================

[](#a-symfony-bundle-to-add-headers-to-your-http-response)

A Symfony bundle to easily send headers in your HTTP response

For Symfony 6.4, 7.x, 8.x

### Usage

[](#usage)

You define one or more headers response in your yaml configuration, for exemple:

```
---
#config/packages/response_header.yml
response_headers:

  headers:
    X-XSS-Protection: value: 1; mode=block

    Referrer-Policy: strict-origin

    Content-Security-Policy:
      - default-src 'none';
      - script-src 'self' data: 'unsafe-inline' 'unsafe-hashes' 'unsafe-eval';
      - script-src-elem 'self' data: 'unsafe-inline' 'unsafe-hashes' 'unsafe-eval';
      - img-src 'self' data: localhost *.mydite.com;

    X-Frame-Options:
      value: SAMEORIGIN
      condition: "'%env(APP_SERVER_TYPE)%' == 'local'"
      replace: false

    Expires:
      value: 0
      condition: request.getPathInfo() matches '^/admin'
...

```

#### Conditonal header

[](#conditonal-header)

The conditional is made with symfony expression language, the available variables are:

```
response_headers:
  headers:
    X-Frame-Options:
      value: SAMEORIGIN
      condition: "'%env(APP_SERVER_TYPE)%' == 'local'"

```

The 'X-Frame-Option' header will be inclued in the HTTP response if the 'APP\_SERVER\_TYPE' environment variable is equal to 'local'.

```
  %env(name)%  : a value from environement
  request: An instance of the class Symfony\Component\HttpFoundation\Request class
  response: An instance of the class Symfony\Component\HttpFoundation\Response class

```

Example:

```
   condition: request.getPathInfo()  matches '^/admin'
   condition: response.getStatusCode() == 200

```

#### Header values ​​in array or scalar format

[](#header-values-in-array-or-scalar-format)

For very long headers, it is possible to use a table format. The header value will be reduced to a single line.

##### line format

[](#line-format)

```
response_headers:

  headers:
    Content-Security-Policy:
      - default-src 'none';
      - script-src 'self' data: 'unsafe-inline' 'unsafe-hashes' 'unsafe-eval';
      - img-src 'self' data: localhost *.mysite.com;
      format: string

```

This is the default format

##### Result:

[](#result)

```
Content-Security-Policy: default-src 'none';script-src 'self' data: 'unsafe-inline';img-src 'self' data: localhost *.mysite.com

```

##### mutliple format

[](#mutliple-format)

But it's possible to have one more than one HTTP header with the same name

```
response_headers:
  headers:
    Accept:
      - application/json
      - application/xml
      format: array

```

##### Result:

[](#result-1)

```
Accept: application/json
Accept: application/xml

```

Installation
------------

[](#installation)

The bundle should be automatically enabled by Symfony Flex. If you don't use Flex, you'll need to enable it manually as explained in the docs.

```
composer config extra.symfony.allow-contrib true
composer require republique-et-canton-de-geneve/response-headers-bundle

```

License Released under the Apache-2.0 license

Quality and test code
---------------------

[](#quality-and-test-code)

Code coverage : [![coverage line](https://raw.githubusercontent.com/republique-et-canton-de-geneve/response-headers-bundle/refs/heads/main/coverage_line.svg)](https://raw.githubusercontent.com/republique-et-canton-de-geneve/response-headers-bundle/refs/heads/main/coverage_line.svg)[![coverage branche](https://raw.githubusercontent.com/republique-et-canton-de-geneve/response-headers-bundle/refs/heads/main/coverage_branch.svg)](https://raw.githubusercontent.com/republique-et-canton-de-geneve/response-headers-bundle/refs/heads/main/coverage_branch.svg)

[![phpunit](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/phpunit.yml/badge.svg)](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/phpunit.yml)[![phpstan](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/phpstan.yml/badge.svg)](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/phpstan.yml)[![rector](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/rector.yml/badge.svg)](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/rector.yml)[![php-cs-fixer](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/republique-et-canton-de-geneve/response-headers-bundle/actions/workflows/php-cs-fixer.yml)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance75

Regular maintenance activity

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

135d ago

PHP version history (2 changes)1.0PHP &gt;=7.4

1.0.4PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bae0e90496575fdc1002163a0a9a0e9564288392a06b252b81555b771ee57f9?d=identicon)[athos99](/maintainers/athos99)

---

Top Contributors

[![athos99](https://avatars.githubusercontent.com/u/208224?v=4)](https://github.com/athos99 "athos99 (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

bundleheadersheaders-securityphpsymfonyhttpresponsesymfonybundleheaderheaderscondtion

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/republique-et-canton-de-geneve-response-headers-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/republique-et-canton-de-geneve-response-headers-bundle/health.svg)](https://phpackages.com/packages/republique-et-canton-de-geneve-response-headers-bundle)
```

###  Alternatives

[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
