PHPackages                             middlewares/referrer-spam - 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. middlewares/referrer-spam

ActiveLibrary[HTTP &amp; Networking](/categories/http)

middlewares/referrer-spam
=========================

Middleware to block referrer spammers

v2.1.0(1y ago)1159.4k2[1 issues](https://github.com/middlewares/referrer-spam/issues)1MITPHPPHP ^7.2 || ^8.0CI passing

Since Oct 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/middlewares/referrer-spam)[ Packagist](https://packagist.org/packages/middlewares/referrer-spam)[ Docs](https://github.com/middlewares/referrer-spam)[ RSS](/packages/middlewares-referrer-spam/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (15)Used By (1)

middlewares/referrer-spam
=========================

[](#middlewaresreferrer-spam)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a8ae0480e31d140ba0a6746d62c4c04bde03416ebebadbba2c4fb80871e29fc0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6964646c6577617265732f72656665727265722d7370616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/middlewares/referrer-spam)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Testing](https://github.com/middlewares/referrer-spam/workflows/testing/badge.svg)](https://github.com/middlewares/referrer-spam/workflows/testing/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/51fd8b5697c3d45122e3125c9881cfc82c3ca96254a2e716d97e23d0fc3a8628/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6964646c6577617265732f72656665727265722d7370616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/middlewares/referrer-spam)

Middleware to block referrer spammers using [matomo/referrer-spam-blacklist](https://github.com/matomo-org/referrer-spam-blacklist). It returns a `403` response if the url host in the `Referer` header is in the blacklist.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2
- A [PSR-7 http library](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations)
- A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)

`ext-intl` PHP extension is recommended otherwise [symfony/polyfill-intl-idn](https://github.com/symfony/polyfill-intl-idn) is used.

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

[](#installation)

This package is installable and autoloadable via Composer as [middlewares/referrer-spam](https://packagist.org/packages/middlewares/referrer-spam).

```
composer require middlewares/referrer-spam
```

Usage
-----

[](#usage)

By default, use `matomo/referrer-spam-blacklist` as a list of spammers

```
$spam = new Middlewares\ReferrerSpam();
```

But you can configure a custom spam list if you don't want to use the default:

```
$spammers = [
    'http://www.0n-line.tv',
    'http://холодныйобзвон.рф',
];

$spam = new Middlewares\ReferrerSpam($spammers);
```

Optionally, you can provide a `Psr\Http\Message\ResponseFactoryInterface` as the second argument to create the error responses (`403`). If it's not defined, [Middleware\\Utils\\Factory](https://github.com/middlewares/utils#factory) will be used to detect it automatically.

```
$responseFactory = new MyOwnResponseFactory();

$spam = new Middlewares\ReferrerSpam($spammers, $responseFactory);
```

---

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance43

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~237 days

Recently: every ~405 days

Total

14

Last Release

422d ago

Major Versions

v0.5.0 → v1.0.02018-01-27

v1.2.0 → v2.0.02019-12-07

PHP version history (4 changes)v0.1.0PHP ^5.6 || ^7.0

v0.5.0PHP ^7.0

v2.0.0PHP ^7.2

v2.0.2PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e99df56b617f4af8cf0556a51a0ca20c7420104920c57d7e9eab093f92bb744f?d=identicon)[oscarotero](/maintainers/oscarotero)

![](https://www.gravatar.com/avatar/42e0d72f42eb7d84f67e20d28606da42e5a3248ca908b1eadb4366aafeae2561?d=identicon)[filisko](/maintainers/filisko)

---

Top Contributors

[![oscarotero](https://avatars.githubusercontent.com/u/377873?v=4)](https://github.com/oscarotero "oscarotero (60 commits)")[![filisko](https://avatars.githubusercontent.com/u/8798694?v=4)](https://github.com/filisko "filisko (4 commits)")[![ncou](https://avatars.githubusercontent.com/u/16743322?v=4)](https://github.com/ncou "ncou (3 commits)")[![mimmi20](https://avatars.githubusercontent.com/u/1120192?v=4)](https://github.com/mimmi20 "mimmi20 (2 commits)")[![MekDrop](https://avatars.githubusercontent.com/u/342641?v=4)](https://github.com/MekDrop "MekDrop (1 commits)")

---

Tags

httpmiddlewarepsr-15spam-filteringhttppsr-7middlewaresecurityspampsr-15refererreferrer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/middlewares-referrer-spam/health.svg)

```
[![Health](https://phpackages.com/badges/middlewares-referrer-spam/health.svg)](https://phpackages.com/packages/middlewares-referrer-spam)
```

###  Alternatives

[middlewares/request-handler

Middleware to execute request handlers

451.6M26](/packages/middlewares-request-handler)[middlewares/firewall

Middleware to provide IP filtering

12318.3k2](/packages/middlewares-firewall)[middlewares/fast-route

Middleware to use FastRoute

96191.1k15](/packages/middlewares-fast-route)[middlewares/negotiation

Middleware to implement content negotiation

47442.1k11](/packages/middlewares-negotiation)[middlewares/cors

Middleware to implement Cross-Origin Resource Sharing (CORS)

1372.2k3](/packages/middlewares-cors)[middlewares/trailing-slash

Middleware to normalize the trailing slash of the uri path

32506.3k11](/packages/middlewares-trailing-slash)

PHPackages © 2026

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