PHPackages                             pod-point/laravel-configcat - 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. pod-point/laravel-configcat

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

pod-point/laravel-configcat
===========================

Implement feature flags with ConfigCat cloud service

4.1.0(1y ago)26.4k2[1 issues](https://github.com/Pod-Point/laravel-configcat/issues)MITPHPPHP ^8.1

Since Feb 20Pushed 1y ago6 watchersCompare

[ Source](https://github.com/Pod-Point/laravel-configcat)[ Packagist](https://packagist.org/packages/pod-point/laravel-configcat)[ Docs](https://github.com/pod-point/laravel-configcat)[ RSS](/packages/pod-point-laravel-configcat/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (11)Used By (0)

Laravel ConfigCat
=================

[](#laravel-configcat)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6323e6dcd1d509949793e195098e655683deb98550644c853e05cceb3ab391ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f642d706f696e742f6c61726176656c2d636f6e6669676361742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pod-point/laravel-configcat)[![GitHub Workflow Status](https://camo.githubusercontent.com/cc06b943a976c13e84941e36aba765eb89b83d9ddbdb2a7ae9b38a8c089233f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706f642d706f696e742f6c61726176656c2d636f6e6669676361742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)](https://camo.githubusercontent.com/cc06b943a976c13e84941e36aba765eb89b83d9ddbdb2a7ae9b38a8c089233f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706f642d706f696e742f6c61726176656c2d636f6e6669676361742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/Pod-Point/laravel-configcat/blob/main/LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/927ed7ba8aa50e1cc11693b9895e7e9b07c85b51ae32e0aa5077ca03c831adf1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706f642d706f696e742f6c61726176656c2d636f6e6669676361742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pod-point/laravel-configcat)

Implement feature flags within your Laravel application using [ConfigCat](https://configcat.com) cloud service.

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

[](#installation)

You can install the package via composer:

```
composer require pod-point/laravel-configcat
```

For Laravel 5.4 up to 9.x

```
composer require pod-point/laravel-configcat:^3.0
```

### Publishing the config file

[](#publishing-the-config-file)

Next, you should publish the Laravel package configuration file using the `vendor:publish` Artisan command. It will be placed in your application's config directory:

```
php artisan vendor:publish --provider="PodPoint\ConfigCat\ConfigCatServiceProvider"
```

Don't forget to specify your [ConfigCat SDK `key`](https://app.configcat.com/sdkkey) within the freshly published Laravel configuration file under `config/configcat.php`.

The Laravel configuration for this package comes with sensible defaults. See [`config/configcat.php`](https://github.com/Pod-Point/laravel-configcat/blob/main/config/configcat.php) for more details.

Usage
-----

[](#usage)

### Facade &amp; global helper

[](#facade--global-helper)

The `ConfigCat` facade as well as the global helper can be used to retrieve the actual value of the feature flag, text or number setting:

```
use PodPoint\ConfigCat\Facades\ConfigCat;

$flag = ConfigCat::get('new_registration_flow');

$flag = configcat('new_registration_flow');
```

> **Note:** You can define the actual value of a feature flag to be `bool(true)` or `bool(false)` on ConfigCat but not only, it can also be [a number or a text setting](https://configcat.com/docs/main-concepts/#about-setting-types).

If the feature flag is undefined or something went wrong, `bool(false)` will be returned by default, however you can change this by specifying a default value **only when using the Facade or the global helper** to retrieve the feature flag value using:

```
use PodPoint\ConfigCat\Facades\ConfigCat;

$flag = ConfigCat::get('new_registration_flow', true);

$flag = configcat('new_registration_flow', true);
```

You can also globally sepcify a default value from the [`config/configcat.php`](https://github.com/Pod-Point/laravel-configcat/blob/main/config/configcat.php) file.

⚠️ **Only** `boolean`, `string`, `integer` or `float` default value types are supported as these are the only [setting types](https://configcat.com/docs/main-concepts/#about-setting-types) available from ConfigCat.

### Validation rule

[](#validation-rule)

Given the following validation rules:

```
Validator::make([
    'email' => 'taylor@laravel.com',
    'username' => 'taylor',
], [
    'email' => 'required_if_configcat:new_registration_flow,true',
    'username' => 'required_if_configcat:new_registration_flow,false',
]);
```

- When the feature flag is **on**
    - The `email` will be a required field
    - The `username` will be an optional field
- When the feature flag is **off**, undefined, a text or number setting
    - The `email` will be an optional field
    - The `username` will be a required field

### HTTP middleware

[](#http-middleware)

The following route will only be accessible if the [feature flag](https://configcat.com/docs/main-concepts/#about-setting-types) is truthy, otherwise a `404` will be thrown.

```
Router::get('/registration')->middleware('configcat.on:new_registration_flow');
```

The opposite is possible, also throwing a `404` if the feature flag is falsy:

```
Router::get('/sign-up')->middleware('configcat.off:new_registration_flow');
```

**Note:** undefined, text or number settings will be considered as feature flags turned `off`.

### Blade directive

[](#blade-directive)

The following view content will only be rendered if the feature flag is truthy:

```
@configcat('new_registration_flow')
    New registration form
@endconfigcat
```

```
@unlessconfigcat('new_registration_flow')
    Old registration form
@endconfigcat
```

```
@configcat('new_registration_flow_1')
    Sign up
@elseconfigcat('new_registration_flow_2')
    Get started
@else
    Register
@endconfigcat
```

**Note:** undefined, text or number settings will be considered as feature flags turned `off`.

Advanced usage
--------------

[](#advanced-usage)

### User targeting

[](#user-targeting)

The [User Object](https://configcat.com/docs/sdk-reference/php/#user-object) is essential if you'd like to use ConfigCat's [Targeting](https://configcat.com/docs/advanced/targeting) feature.

ConfigCat needs to understand the representation of your users from your application. To do so, you will need to transform your user into a `ConfigCat\User` object. This can be done directly from the [`config/configcat.php`](https://github.com/Pod-Point/laravel-configcat/blob/main/config/configcat.php) file. Here is an example:

```
'user' => \PodPoint\ConfigCat\Support\DefaultUserTransformer::class,
```

Which will be using a sensible default transformer:

```
class DefaultUserTransformer
{
    public function __invoke(\Illuminate\Foundation\Auth\User $user)
    {
        return new \ConfigCat\User($user->getKey(), $user->email);
    }
}
```

Feel free to create your own transformer class and use it instead, just **remember** that it needs to be **callable** with the `__invoke()` function.

> **Note:** for security reasons, all of the logic computation for the user targeting is executed on your application side of things using ConfigCat's SDK. No user details will be leaving your application in order find out wether or not a user should have a feature flag enabled or not.

Once you have defined your mapping, you will be able to explicitly use the representation of your user when checking a feature flag:

```
use App\Models\User;
use PodPoint\ConfigCat\Facades\ConfigCat;

$user = User::where('email', 'taylor@laravel.com')->firstOrFail();
ConfigCat::get('new_registration_flow', $default, $user);
```

This is also applicable for the global helper and the Blade directive:

```
configcat('new_registration_flow', $default, $user);
```

```
@configcat('new_registration_flow', $user)
    New registration form
@endconfigcat
```

> **Note:** if you have defined your user mapping but are not explicitly using a specific user when checking for a flag, we will automatically try to use the logged in user, if any, for convenience.

### Caching &amp; logging

[](#caching--logging)

This package supports native Laravel caching and logging capabilities in order to cache the feature flag values from ConfigCat's CDN as well as log any information when resolving feature flags. We've setup some sensible defaults but various levels of caching and logging can be configured.

See [`config/configcat.php`](https://github.com/Pod-Point/laravel-configcat/blob/main/config/configcat.php) for more info.

### Test support: mock, fake &amp; overrides

[](#test-support-mock-fake--overrides)

#### In-memory testing

[](#in-memory-testing)

When writing unit or functional tests, you may need to be able to mock or fake this package completely so you can test various behaviors within your application. This is all possible through the powerful Facade.

**Mocking:**

```
use PodPoint\ConfigCat\Facades\ConfigCat;

ConfigCat::shouldReceive('get')
    ->once()
    ->with('new_registration_flow')
    ->andReturn(true);
```

See  for more info.

**Fake:**

Faking it will prevent the package to genuinely try to hit ConfigCat's CDN:

```
use PodPoint\ConfigCat\Facades\ConfigCat;

// you can fake it
ConfigCat::fake();
// optionally setup some predefined feature flags for your test
ConfigCat::fake(['new_registration_flow' => true]);
```

#### End-to-end testing

[](#end-to-end-testing)

When running tests within a browser which doesn't share the same instance of the application, using mocks or fakes is not applicable. This is why we provide some overrides through ConfigCat SDK which will make the client under the hood localhost only and will use a locally generated `json` file in order to read the feature flags for the system under test.

First of all, you will need to make sure to enable `overrides` from [`config/configcat.php`](https://github.com/Pod-Point/laravel-configcat/blob/main/config/configcat.php). You could also optionally tweak the file path for the `json` file if you wish to. The file will be automatically created for you when using overrides.

Similarly to `ConfigCat::fake()` you can come up with some predefined feature flags which will be saved into a `json` file:

```
use PodPoint\ConfigCat\Facades\ConfigCat;

ConfigCat::override(['new_registration_flow' => true]);
```

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see our [Releases](https://github.com/pod-point/laravel-configcat/releases) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/Pod-Point/laravel-configcat/blob/main/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [configcat/php-sdk](https://github.com/configcat/php-sdk)
- [ylsideas/feature-flags](https://github.com/ylsideas/feature-flags) for inspiration
- [Pod Point](https://github.com/pod-point)
- [All Contributors](https://github.com/pod-point/laravel-configcat/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/Pod-Point/laravel-configcat/blob/main/LICENSE.md) for more information.

---

[![](https://camo.githubusercontent.com/f4e0528c60cd8c08e38e692e563e51b73985babc2fd1a0c2684e286fff6be9cd/68747470733a2f2f6433683235366e33627a697070702e636c6f756466726f6e742e6e65742f706f642d706f696e742d6c6f676f2e737667)](https://camo.githubusercontent.com/f4e0528c60cd8c08e38e692e563e51b73985babc2fd1a0c2684e286fff6be9cd/68747470733a2f2f6433683235366e33627a697070702e636c6f756466726f6e742e6e65742f706f642d706f696e742d6c6f676f2e737667)

Travel shouldn't damage the earth 🌍

Made with ❤️ at [Pod Point](https://pod-point.com)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% 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 ~73 days

Recently: every ~146 days

Total

10

Last Release

564d ago

Major Versions

1.2.1 → 2.0.02023-02-23

2.0.0 → 3.0.02023-05-11

3.1.0 → 4.0.02024-05-23

PHP version history (3 changes)1.0.0PHP &gt;=7.1

4.0.0PHP &gt;=8.1

4.1.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ce40bc096123bdd8dabab907d789c0de2ebd015fc4d1a11b692faa85be8e4ec?d=identicon)[pod-point](/maintainers/pod-point)

---

Top Contributors

[![clemblanco](https://avatars.githubusercontent.com/u/668419?v=4)](https://github.com/clemblanco "clemblanco (28 commits)")[![HasnatH](https://avatars.githubusercontent.com/u/3200859?v=4)](https://github.com/HasnatH "HasnatH (1 commits)")

---

Tags

configcatfeature-flagslaravellaravel-packagelaravelflagsfeatureconfigcatpod-point

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/pod-point-laravel-configcat/health.svg)

```
[![Health](https://phpackages.com/badges/pod-point-laravel-configcat/health.svg)](https://phpackages.com/packages/pod-point-laravel-configcat)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[codinglabsau/laravel-feature-flags

Dynamic feature flags for laravel.

3891.0k](/packages/codinglabsau-laravel-feature-flags)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)[offload-project/laravel-toggle

A simple and flexible feature toggle (feature flag) package for Laravel

251.6k](/packages/offload-project-laravel-toggle)

PHPackages © 2026

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