PHPackages                             cloakings/cloakings-common - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cloakings/cloakings-common

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cloakings/cloakings-common
==========================

Cloakings common library

1.6.0(1mo ago)33.6k↓66.7%24MITPHPPHP ^8.4

Since Oct 2Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/cloakings/cloakings-common)[ Packagist](https://packagist.org/packages/cloakings/cloakings-common)[ RSS](/packages/cloakings-cloakings-common/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (5)Versions (13)Used By (4)

Cloakings Common Library
========================

[](#cloakings-common-library)

Detect if user is bot or real user.

Install
-------

[](#install)

```
composer require cloakings/cloakings-common
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

If there is library that fits your needs and implements `CloakerInterface` - use it.

```
use Cloakings\CloakingsCommon\CloakerFactory;
use Cloakings\CloakingsCommon\CloakModeEnum;
use Cloakings\CloakingsCommon\SampleCloaker;

$cloaker = new SampleCloaker();
// or
$cloaker = (new CloakerFactory())->create(SampleCloaker::class);

$result = $cloaker->handle(new Request(server: ['HTTP_USER_AGENT' => 'Chrome 100']));
// $result->mode === CloakModeEnum::Real
// show real site

$result = $cloaker->handle(new Request(server: ['HTTP_USER_AGENT' => 'GoogleBot', 'REMOTE_ADDR' => '8.8.8.8']));
// $result->mode === CloakModeEnum::Fake
// show fake site

$result = $cloaker->handle(new Request(server: ['HTTP_USER_AGENT' => 'GoogleBot', 'REMOTE_ADDR' => '11.22.33.44']));
// $result->mode === CloakModeEnum::Response
// stop and show this response

$result = $cloaker->handle(new Request()); // no user agent
// $result->mode === CloakModeEnum::Error
// decide by yourself: may be show default (fake or real) site, may be try chaining decision to another cloaker
```

### Chaining

[](#chaining)

If you want visitor to pass several cloakers then use `ChainCloaker`

```
use Cloakings\CloakingsCommon\AlwaysRealCloaker;
use Cloakings\CloakingsCommon\CloakerFactory;
use Cloakings\CloakingsCommon\SampleCloaker;

$cloaker = (new CloakerFactory())->createChain([
    AlwaysRealCloaker::class,
    SampleCloaker::class,
]);
```

Logic:

- if cloaker tells "Fake" - stop and return "Fake"
- if cloaker tells "Response" - stop and return "Response"
- if cloaker tells "Real" - continue to the next cloaker; return last "Real" response
- if cloaker tells "Error" - continue to the next cloaker; return last "Real" response; if all cloakers return "Error" then return last "Error"

Create own Cloaker
------------------

[](#create-own-cloaker)

Implement `CloakerInterface`.

Return `mode`:

- "Real": it seems that visitor is real human user
- "Fake": it seems that visitor is bot user
- "Response": don't show fake or real site but this response: usually temp pages for additional checks like captcha or js challenge
- "Error": cannot decide

Return `response`: used only in mode "Response" or "Error"

Return `probability`: how sure you are `0.0 - 1.0`. Useful if you have several cloakers and one says "Real", another says "Fake" and you want to decide. Usually just keep default `1.0`.

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance92

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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

Every ~120 days

Recently: every ~313 days

Total

12

Last Release

38d ago

PHP version history (3 changes)1.0PHP &gt;=8.1

1.5.0PHP &gt;=8.3

1.6.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/df3e7060fb5777768e7bb133e98b1e7dfcc788f25fe6dc445acf7036da5c0c3e?d=identicon)[luchaninov](/maintainers/luchaninov)

---

Top Contributors

[![luchaninov](https://avatars.githubusercontent.com/u/3829796?v=4)](https://github.com/luchaninov "luchaninov (12 commits)")

---

Tags

blackhatcloakingphpphp-librarytraffictraffic-analysis

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cloakings-cloakings-common/health.svg)

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

###  Alternatives

[illuminate/session

The Illuminate Session package.

9938.5M822](/packages/illuminate-session)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[symfony/ux-autocomplete

JavaScript Autocomplete functionality for Symfony

635.5M36](/packages/symfony-ux-autocomplete)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)[numero2/contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data

121.6k](/packages/numero2-contao-storelocator)

PHPackages © 2026

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