PHPackages                             psuw/common-listener - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. psuw/common-listener

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

psuw/common-listener
====================

Expression evaluating common listeners

1.0.0(5y ago)03MITPHPPHP ^7.0

Since Sep 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/PawelSuwinski/common-listener)[ Packagist](https://packagist.org/packages/psuw/common-listener)[ RSS](/packages/psuw-common-listener/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

README
======

[](#readme)

This file is part of the PsuwCommonListener package.

```
@package PsuwCommonListener
@copyright Copyright (c) 2019, Paweł Suwiński
@author Paweł Suwiński
@license MIT

```

Example of usage
----------------

[](#example-of-usage)

```
# config.yml

services:
# (...)

    # Adds secure headers to every response.
    secure_headers_response:
        class: Psuw\CommonListener\EventListener\ExpressionEvaluatingListener
        arguments:
            -
                headers:
                  X-Frame-Options: SAMEORIGIN
                  X-XSS-Protection: '1; mode=block'
                  X-Content-Type-Options: nosniff
                  Referrer-Policy: same-origin
        calls: [[addExpression, ["event.getResponse().headers.add(headers)"]]]
        tags: [{ name: kernel.event_listener, event: kernel.response, method: onEvent }]

    # HTML to CSV converter: allows tables download to use with spreadsheet.
    html2csv_converter:
        class: Psuw\CommonListener\HttpKernel\EventListener\ConvertResponseListener
        arguments:
            - 'event.getResponse().headers.get("Content-Type", "text/html")  == "text/html" && event.getRequest().getRequestFormat() == "csv"'
            - 'bariew\html2csv\Html2Csv'
            -
               - 'event.getResponse().headers.set("Content-Type", "text/csv")'
               - "converter.toFile(event.getRequest().server.get('REQUEST_TIME') ~ '.csv')"
        tags: [{ name: kernel.event_listener, event: kernel.response }]

    # CSRF Token Validation
    #
    # Logs the case and throws Access Denied Exception if token is not initialized
    # at session level, not present in reqest or not equal. For that purpose two
    # extra methods of expressions language needed to be registered (`hash_equals`
    # and `json_encode`).
    csrf_validation:
        class: Psuw\CommonListener\HttpKernel\EventListener\ThrowIfListener
        calls:
            - [setExpressionLanguage, ['@expression_language']]
            - [setContext, [{name: '_csrf_token', logger: "@=service('logger').withName('security')"}]]
        arguments:
            - >
              event.getRequest().isMethod('POST') &&
              (event.getRequest().getSession().get(name) == null ||
              !event.getRequest().request.has(name) ||
              !hash_equals(event.getRequest().getSession().get(name), event.getRequest().request.get(name))) &&
              (logger.error('csrf invalid: expected ' ~ name ~ ': ' ~  event.getRequest().getSession().get(name) ~ ' in request ' ~ json_encode(event.getRequest().request.all())) || true)
        tags: [{ name: kernel.event_listener, event: kernel.request, method: onEvent, priority: 100}]
    expression_language:
        class: Symfony\Component\ExpressionLanguage\ExpressionLanguage
        calls:
            - [registerProvider, ['@expression_language_provider']]
    expression_language_provider:
        class: Psuw\CommonListener\Expression\FunctionExpressionLanguageProvider
        arguments: [['json_encode', 'hash_equals']]

```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f97eb6342e07115fbad8a50e4f6e0777d6fc31374e81bf303ad9aec66f6536f?d=identicon)[dracono@wp.pl](/maintainers/dracono@wp.pl)

---

Top Contributors

[![PawelSuwinski](https://avatars.githubusercontent.com/u/1256986?v=4)](https://github.com/PawelSuwinski "PawelSuwinski (3 commits)")

---

Tags

phpsymfony

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/psuw-common-listener/health.svg)

```
[![Health](https://phpackages.com/badges/psuw-common-listener/health.svg)](https://phpackages.com/packages/psuw-common-listener)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M728](/packages/sylius-sylius)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.7M1.0k](/packages/phpro-grumphp)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M503](/packages/pimcore-pimcore)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M199](/packages/sulu-sulu)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k40](/packages/civicrm-civicrm-core)

PHPackages © 2026

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