PHPackages                             ipapikas/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. ipapikas/gatekeeper

ActiveLibrary

ipapikas/gatekeeper
===================

GateKeeper allows you to hide part of your product and make it active under given circumstances.

v1.0.0(9y ago)9171MITPHPPHP &gt;=5.5.9

Since Feb 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ioannis-papikas/gatekeeper)[ Packagist](https://packagist.org/packages/ipapikas/gatekeeper)[ RSS](/packages/ipapikas-gatekeeper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

GateKeeper
==========

[](#gatekeeper)

GateKeeper allows you to hide part of your product and make it active under given circumstances.

[![StyleCI](https://camo.githubusercontent.com/c079be0d5ba48810f684462ebc695e1b745f95b7029ce341889acb078c56a62d/68747470733a2f2f7374796c6563692e696f2f7265706f732f37343736353134382f736869656c64)](https://styleci.io/repos/74765148)

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

[](#installation)

You can install the GateKeeper simply by adding the files into your project or using the composer.

### Through the composer

[](#through-the-composer)

Add the following line to your `composer.json` file:

```
"ipapikas/gatekeeper": "~1.0"

```

Using GateKeeper
----------------

[](#using-gatekeeper)

Gatekeeper works with **gates** and with **keepers**.

**Gates** are special software doors that should allow the execution flow when they are open and deny (or do something else) when they are closed. They have a name and a set of keepers.

**Keepers** are a number of conditions on every gate that decide whether the gate will open or close. On this approach, in order for the gate to open, all the keepers must “allow access”.

### How To

[](#how-to)

GateKeeper library consists of two parts, the initialization and the gate check.

The initialization should usually happen when the application starts, so it can be part of the application bootstrap:

**Initialization**

```
// [GateKeeperBootstrap].php

use Gatekeeper\Gate;
use Gatekeeper\GateKeeper;
use Gatekeeper\GateRegistry;
use Gatekeeper\Keeper\DateTimeKeeper;
use Gatekeeper\Keeper\IpAddressKeeper;

// Get / Mock (Symfony) Request object
$request = new \Symfony\Component\HttpFoundation\Request();

// Initialize a gate registry
$registry = new GateRegistry();

// Create a gate that will be activated only for January 2017
$keeper = new DateTimeKeeper(new \DateTime('2017-01-01'), new \DateTime('2017-02-01'));
$gate = new Gate('January-Feature', $keeper);
$registry->register($gate);

// Create a gate that will allow access only from a specific sub-network
$keeper = new IpAddressKeeper($request, ['10.1.1.0/24'], ['20.0.1.0/24']);
$gate = new Gate('Ip-Specific-Feature', $keeper);
$registry->register($gate);

// Setup GateKeeper and set to a container (or create a singleton)
$gateKeeper = new GateKeeper($registry);
$container->set(GateKeeper::class, $gateKeeper);
```

**Gate Check**

```
// example.php

// At any point in our code, we can simply get the GateKeeper and check any gate
// Using a container (like PHP-DI) or a singleton that we have already created
$gateKeeper = $container->get(GateKeeper::class);

// Check gate
if ($gateKeeper->checkGate('January-Feature')) {
    // Gate is open
    echo 'gate is open';
} else {
    // Gate is closed
    echo 'gate is closed';
}
```

### Create a custom Keeper

[](#create-a-custom-keeper)

You can easily create your own custom keeper that will have its own logic. The logic can include simple conditions like the weather or build more complex logic based on your user profiles or even custom beta tester programs and so on.

Here is an example of how to build a proper keeper:

```
// MyKeeper.php

namespace MyProject\Gatekeeper\Keeper;

use Gatekeeper\Keeper\AbstractKeeper;

class MyKeeper extends AbstractKeeper
{
    /**
     * Implementation of keeper allow() function logic.
     */
    public function allow()
    {
        // Implement your allow logic anyway you believe that suits your product
        // Remember, it has to return true for the gate to open (along with the rest of the keepers)
    }
}
```

```
// [GateKeeperBootstrap].php

use Gatekeeper\Gate;
use Gatekeeper\GateKeeper;
use Gatekeeper\GateRegistry;
use MyProject\Gatekeeper\Keeper\MyKeeper;

// Initialize a gate registry
$registry = new GateRegistry();

// Create a gate with MyKeeper
$keeper = new MyKeeper();
$gate = new Gate('My-Feature', $keeper);
$registry->register($gate);

// Create GateKeeper
$gateKeeper = new GateKeeper($registry);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3359d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/753e0ad67caebf12b98c1f6db52014667aaa22d5c7c5b87f68f70875e9399135?d=identicon)[ioannis-papikas](/maintainers/ioannis-papikas)

---

Top Contributors

[![ioannis-papikas](https://avatars.githubusercontent.com/u/2780884?v=4)](https://github.com/ioannis-papikas "ioannis-papikas (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.5k9.4M48](/packages/laravel-reverb)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k4](/packages/elgg-elgg)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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