PHPackages                             secondtruth/gatekeeper - 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. [Security](/categories/security)
4. /
5. secondtruth/gatekeeper

ActiveLibrary[Security](/categories/security)

secondtruth/gatekeeper
======================

Prevent spammers from ever reading your site

2052PHP

Since May 18Pushed 1y ago8 watchersCompare

[ Source](https://github.com/secondtruth/gatekeeper)[ Packagist](https://packagist.org/packages/secondtruth/gatekeeper)[ RSS](/packages/secondtruth-gatekeeper/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Gatekeeper
==========

[](#gatekeeper)

[![Build Status](https://camo.githubusercontent.com/d68e1b88125a999a7ce7ad0a56bd40db315c4769b1f621a6c87b3a058f7e4a1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7365636f6e6474727574682f676174656b65657065722f74657374732e796d6c2e737667)](https://github.com/secondtruth/gatekeeper/actions/workflows/tests.yml)[![Quality](https://camo.githubusercontent.com/c4d80b4777e821c0720a7c13b419ebbced2ad2392435e25954e7e2d6644b246b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f7365636f6e6474727574682f676174656b65657065722e737667)](https://codeclimate.com/github/secondtruth/gatekeeper)[![Coverage](https://camo.githubusercontent.com/123d996fdecf415d965414397394577b9431fe30c9f302a2558699c433b24250/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f7365636f6e6474727574682f676174656b65657065722e7376673f746f6b656e3d706d58367a345548444a)](https://codecov.io/gh/secondtruth/gatekeeper)[![License](https://camo.githubusercontent.com/08ad3501715c46c4067bfc426c3fad857fa3fce7c235e2f30bf21f8e630d0671/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7365636f6e6474727574682f676174656b65657065722e7376673f636f6c6f723d626c7565)](https://packagist.org/packages/secondtruth/gatekeeper)

The Gatekeeper library protects websites from spam and other attacks. It prevents bad bots from delivering their junk, and in many cases, from ever reading your site in the first place.

Description
-----------

[](#description)

Welcome to a whole new way of keeping your service, forum, wiki or content management system free of spam and other attacks. Gatekeeper is a PHP-based solution for blocking spam and the robots which deliver it. This keeps your site's load down, makes your site logs cleaner, and can help prevent denial of service conditions caused by spammers.

Gatekeeper also transcends other anti-spam solutions by working in a completely different, unique way. Instead of merely looking at the content of potential spam, Gatekeeper analyzes the delivery method as well as the software the spammer is using. In this way, Gatekeeper can stop spam attacks even when nobody has ever seen the particular spam before.

Gatekeeper is designed to work alongside existing spam prevention services to increase their effectiveness and efficiency. Whenever possible, you should run it in combination with a more traditional spam prevention service.

The library is inspired by the **Bad Behavior** anti-spam system by **Michael Hampton**.

Usage
-----

[](#usage)

Include the vendor autoloader and use the classes:

```
namespace Acme\MyApplication;

use Secondtruth\Gatekeeper\Screener;
use Secondtruth\Gatekeeper\Gatekeeper;
use Secondtruth\Gatekeeper\ACL\IPAddressACL;
use Secondtruth\Gatekeeper\Check\UrlCheck;
use Secondtruth\Gatekeeper\Listing\IPList;
use Laminas\Diactoros\ServerRequestFactory; // or any other PSR-7 ServerRequest factory

require 'vendor/autoload.php';
```

Create a `Screener` object and add the `Check` object(s) you want to use:

```
$screener = new Screener();

$check = new UrlCheck();
$screener->addCheck($check);
```

Create a `Gatekeeper` object and run it using the screener:

```
$request = ServerRequestFactory::fromGlobals(); // or a PSR-7 ServerRequest object you already have

$gatekeeper = new Gatekeeper();

$allowed = new IPList('127.0.0.1');
$denied = new IPList(['127.0.0.2', '127.0.0.3/32']);
$gatekeeper->addACL(new IPAddressACL($allowed, $denied));

$gatekeeper->run($request, $screener);
```

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

[](#installation)

### Install via Composer

[](#install-via-composer)

[Install Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) if you don't already have it present on your system.

To install the library, run the following command and you will get the latest development version:

```
composer require secondtruth/gatekeeper:dev-master
```

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

[](#requirements)

- You must have at least PHP version 8.1 installed on your system.

Author, Credits and License
---------------------------

[](#author-credits-and-license)

This project was created by [Christian Neff](https://www.secondtruth.de) ([@secondtruth](https://github.com/secondtruth)) and is licensed under the [MIT License](LICENSE.md).

Based on the work of:

- Michael Hampton

Thanks to [all other contributors](https://github.com/secondtruth/wumbo/graphs/contributors)!

###  Health Score

18

—

LowBetter than 9% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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/82268b2432ab90f14c62445938bc3cd1340dc66e0463035df57891826b418016?d=identicon)[secondtruth](/maintainers/secondtruth)

---

Top Contributors

[![secondtruth](https://avatars.githubusercontent.com/u/416441?v=4)](https://github.com/secondtruth "secondtruth (202 commits)")

---

Tags

access-controlcomposerfirewallphpprotect-websitesprotectionspam-preventionweb

### Embed Badge

![Health badge](/badges/secondtruth-gatekeeper/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k158.4M195](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k95.2M5.8k](/packages/roave-security-advisories)[ircmaxell/password-compat

A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password\_hash

2.1k56.3M116](/packages/ircmaxell-password-compat)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.1M95](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41176.1M107](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86816.9M54](/packages/bjeavons-zxcvbn-php)

PHPackages © 2026

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