Prevent spammers from ever reading your site

dev-master 2017-11-02 13:39 UTC

This package is auto-updated.

Last update: 2022-05-11 23:19:22 UTC


Build Status Scrutinizer Coverage License

This 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.


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.


Include the vendor autoloader and use the classes:

namespace Acme\MyApplication;

use FlameCore\Gatekeeper\Screener;
use FlameCore\Gatekeeper\Gatekeeper;
use FlameCore\Gatekeeper\Listing\IPList;
use FlameCore\Gatekeeper\Check\IPBlacklistCheck;
use Symfony\Component\HttpFoundation\Request;

require 'vendor/autoload.php';

Create the Check object(s) you want to use:

$blacklist = new IPList(['', '']);
$check = new IPBlacklistCheck($blacklist);

Create a Screener object and add the checks to it:

$screener = new Screener();
$screener->setWhitelist(new IPList(''));

Create a Gatekeeper object and run it using the screener:

$request = Request::createFromGlobals();

$gatekeeper = new Gatekeeper();
$gatekeeper->run($request, $screener);


Install via Composer

Install Composer if you don't already have it present on your system:

$ curl -sS | php

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

$ php composer.phar require secondtruth/gatekeeper:dev-master


  • You must have at least PHP version 5.6 installed on your system.


If you want to contribute, please see the CONTRIBUTING file first.

Thanks to the contributors:

  • Christian Neff (secondtruth)
  • Michael Hampton