PHPackages                             gabrieljmj/httprefererfilter - 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. gabrieljmj/httprefererfilter

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

gabrieljmj/httprefererfilter
============================

Blocker and allower to HTTP referers

06PHP

Since Nov 7Pushed 11y ago1 watchersCompare

[ Source](https://github.com/GabrielJMJ/HttpRefererFilter)[ Packagist](https://packagist.org/packages/gabrieljmj/httprefererfilter)[ RSS](/packages/gabrieljmj-httprefererfilter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Gabrieljmj\\HttpRefererFilter
=============================

[](#gabrieljmjhttprefererfilter)

[![Total Downloads](https://camo.githubusercontent.com/18514691fab138ae4bac50f070a669c97e9828132a51002ea6c4c16c8ecefe3a/68747470733a2f2f706f7365722e707567782e6f72672f6761627269656c6a6d6a2f687474707265666572657266696c7465722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/gabrieljmj/httprefererfilter) [![Latest Unstable Version](https://camo.githubusercontent.com/3406f5a09ac1212116d54b4a5a83da7c865072b0f60b3ef68af86d09c1eb97e9/68747470733a2f2f706f7365722e707567782e6f72672f6761627269656c6a6d6a2f687474707265666572657266696c7465722f762f756e737461626c652e706e67)](https://packagist.org/packages/gabrieljmj/httprefererfilter) [![License](https://camo.githubusercontent.com/262981156441491da3894aa5bc98ddcfa9e57d07a34955b79d21541fb21bd1a2/68747470733a2f2f706f7365722e707567782e6f72672f6761627269656c6a6d6a2f687474707265666572657266696c7465722f6c6963656e73652e706e67)](https://packagist.org/packages/gabrieljmj/httprefererfilter) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/6f8ede496bdf308e33abec14ced386051acdee46163e3cf67e02d0e5cc57f6b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4761627269656c4a4d4a2f487474705265666572657246696c7465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GabrielJMJ/HttpRefererFilter/?branch=master)

Filter to allow or block HTTP referers.

\##Download Via [Composer](http://getcomposer.org):

```
{
    "require": {
        "gabrieljmj/httprefererfilter": "dev-master"
    }
}
```

\##Blocker actions Blocker actions are actions to be executed when a referer not allowed try a request.

- `\Gabrieljmj\HttpRefererFilter\BlockerAction\RedirectWithHttpLocationHeader`: Redirects to some address. Pass on constructor an instance of `\Symfony\Component\HttpFoundation\RedirectResponse`.
- `\Gabrieljmj\HttpRefererFilter\BlockerAction\PageContent`: Add on the page a content. Pass on constructor the content (string) and an instance of `\Symfony\Component\HttpFoundation\Response`.

\##Blocking You can block specifc HTTP referers. ####Example

```
use Gabrieljmj\HttpRefererFilter\HttpRefererBlocker;
use Gabrieljmj\HttpRefererFilter\BlockerAction\RedirectWithHttpLocationHeader;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

$action = new RedirectWithHttpLocationHeader(new RedirectResponse('http://mydomain.com/invalid-referer');
$blocker = new HttpRefererBlocker();
$blocker->add('http://example.com', $action)
        ->add('http://example2.com', $action);
$request = new Request($_GET, $_POST, [], $_COOKIE, $_FILES, ['HTTP_REFERER' => 'http://example_valid.com']);
var_dump($blocker->validate($request)); //bool(true)
```

If the domain (referer) **is** in the list, redirects to `http://mydomain.com/invalid-referer`.

\##Allowing With it, allow the request just for specifc domains. ####Example

```
use Gabrieljmj\HttpRefererFilter\HttpRefererAllower;
use Gabrieljmj\HttpRefererFilter\BlockerAction\RedirectWithHttpLocationHeader;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

$action = new RedirectWithHttpLocationHeader(new RedirectResponse('http://mydomain.com/invalid-referer');
$blocker = new HttpRefererAllower($action);
$blocker->add('http://example.com')
        ->add('http://example2.com');
$request = new Request($_GET, $_POST, [], $_COOKIE, $_FILES, ['HTTP_REFERER' => 'http://example1.com']);
var_dump($blocker->validate($request)); //bool(true)
```

If the domain (referer) **is not** in the list, redirects to `http://mydomain.com/invalid-referer`.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fcbdf815749595d3dcfd4fb781e2cac05aa6d132123aa9da889d2c5ca6c8e11?d=identicon)[GabrielJMJ](/maintainers/GabrielJMJ)

---

Top Contributors

[![gabrieljmj](https://avatars.githubusercontent.com/u/2223216?v=4)](https://github.com/gabrieljmj "gabrieljmj (13 commits)")

### Embed Badge

![Health badge](/badges/gabrieljmj-httprefererfilter/health.svg)

```
[![Health](https://phpackages.com/badges/gabrieljmj-httprefererfilter/health.svg)](https://phpackages.com/packages/gabrieljmj-httprefererfilter)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M318](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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