Middleware to block referrer spammers

v2.0.2 2020-12-04 00:35 UTC

This package is auto-updated.

Last update: 2022-04-29 00:48:40 UTC


Latest Version on Packagist Software License Testing Total Downloads

Middleware to block referrer spammers using matomo/referrer-spam-blacklist. It returns a 403 response if the url host in the Referer header is in the blacklist.



This package is installable and autoloadable via Composer as middlewares/referrer-spam.

composer require middlewares/referrer-spam


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 = [

$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 will be used to detect it automatically.

$responseFactory = new MyOwnResponseFactory();

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

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

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