PHPackages                             alexssander-cusin/panic-control-laravel - 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. alexssander-cusin/panic-control-laravel

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

alexssander-cusin/panic-control-laravel
=======================================

This is my package panic-control-laravel

v1.3.3(2y ago)013[1 issues](https://github.com/alexssander-cusin/panic-control-laravel/issues)[2 PRs](https://github.com/alexssander-cusin/panic-control-laravel/pulls)MITPHPPHP ^8.1

Since May 26Pushed 2y agoCompare

[ Source](https://github.com/alexssander-cusin/panic-control-laravel)[ Packagist](https://packagist.org/packages/alexssander-cusin/panic-control-laravel)[ Docs](https://github.com/alexssander-cusin/panic-control-laravel)[ RSS](/packages/alexssander-cusin-panic-control-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (15)Versions (10)Used By (0)

Panic Control for Laravel
=========================

[](#panic-control-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/405b3cc9df867b0f33d32e2e1ba79bd7d74c99c143b335032c3f37dd5f86e23d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c65787373616e6465722d637573696e2f70616e69632d636f6e74726f6c2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alexssander-cusin/panic-control-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ac04bc6a4b74c7e8794878f6d469433f1757cb8ca7cb834281cc7674f55c7e58/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c65787373616e6465722d637573696e2f70616e69632d636f6e74726f6c2d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/alexssander-cusin/panic-control-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/093f410e49d7f2402ea45d6b3b65b9308779656b4980953d5158f39f5317aba5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c65787373616e6465722d637573696e2f70616e69632d636f6e74726f6c2d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/alexssander-cusin/panic-control-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ef8d61a7e14d1c5bee90d47df1308bc9f27e5b0329962b8d87a01fc0a5557c89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c65787373616e6465722d637573696e2f70616e69632d636f6e74726f6c2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alexssander-cusin/panic-control-laravel)

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

[](#installation)

You can install the package via composer:

```
composer require alexssander-cusin/panic-control-laravel
```

You can publish the config file with:

```
php artisan vendor:publish --tag="panic-control-laravel-config"
```

This are the contents of the published config file:

```
return [
    /**
     *--------------------------------------------------------------------------
     * Set up what store will be used
     *--------------------------------------------------------------------------
    */

    'default' => 'database',

    'drivers' => [
        'database' => [
            /**
             *--------------------------------------------------------------------------
             * Defines which registered connections
             *--------------------------------------------------------------------------
             * The storage listed in /config/database.php should be used
             */

            'connection' => config('database.default'),

            /**
             *--------------------------------------------------------------------------
             * Define the table name will be created in database
             *--------------------------------------------------------------------------
            */

            'table' => 'panic_controls',
        ],
        'file' => [
            /**
             *--------------------------------------------------------------------------
             * Defines which registered disk
             *--------------------------------------------------------------------------
             * The storage listed in /config/filesystem.php should be used
             *
             * Supported Drivers: "local", "ftp", "sftp", "s3"
            */

            'disk' => config('filesystems.default'),

            /**
             *--------------------------------------------------------------------------
             * Defines the name of the file that will be created
             *--------------------------------------------------------------------------
            */

            'path' => 'panic-control.json',
        ],
        'endpoint' => [
            /**
             *--------------------------------------------------------------------------
             * Defines the URL of the endpoint
             *--------------------------------------------------------------------------
             */
            'url' => 'https://localhost/panic-control.json',
        ],
    ],
    'cache' => [
        /**
         *--------------------------------------------------------------------------
         * Activates the cache usage for the panic controls
         *--------------------------------------------------------------------------
        */

        'enabled' => true,

        /**
         *--------------------------------------------------------------------------
         * Defines what cache store should be used
         *--------------------------------------------------------------------------
         * The storage listed in /config/cache.php should be used
         *
         * Supported drivers: "apc", "array", "database", "file",
         *      "memcached", "redis", "dynamodb", "octane", "null"
        */

        'store' => env('CACHE_DRIVER', 'file'),

        /**
         *--------------------------------------------------------------------------
         * Cache Key Prefix
         *--------------------------------------------------------------------------
         *
         * When utilizing the APC, database, memcached, Redis, or DynamoDB cache
         * stores there might be other applications using the same cache. For
         * that reason, you may prefix every cache key to avoid collisions.
         *
        */

        'key' => 'panic-control',

        /**
         *--------------------------------------------------------------------------
         * Sets the time the cache will expire
         *--------------------------------------------------------------------------
        */

        'ttl' => 60,
    ],

    /**
     *--------------------------------------------------------------------------
     * List custom rules
     *--------------------------------------------------------------------------
    */

    'rules' => [
        'route-name' => PanicControl\Rules\RouteName::class,
        'url-path' => PanicControl\Rules\UrlPath::class,
        'sampling' => PanicControl\Rules\Sampling::class,
        'user' => PanicControl\Rules\User::class,
    ],
];
```

You can publish and run the migrations with (only for database store):

```
php artisan vendor:publish --tag="panic-control-laravel-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

### Facade

[](#facade)

Create a Panic Control [1](#user-content-fn-1-e9c1771cf2a453992077ed6a256f2247)

```
use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => false,
]);
```

Update a Panic Control [1](#user-content-fn-1-e9c1771cf2a453992077ed6a256f2247)

```
use PanicControl\Facades\PanicControl;

$panic = 'panic-control-name'; //Panic Control Name or ID

PanicControl::edit($panic, [
    'name' => 'new-panic-control-name',
]);
```

Get all Panic Control

```
use PanicControl\Facades\PanicControl;

PanicControl::all();
```

Get a Panic Control

```
use PanicControl\Facades\PanicControl;

PanicControl::find('panic-control-name');
```

Check if Panic Control is Active

```
use PanicControl\Facades\PanicControl;

PanicControl::check('panic-control-name');
```

### Helper

[](#helper)

Check if Panic Control is Active

```
getPanicControlActive('panic-control-name');
```

### Command

[](#command)

List all Panic Control

```
php artisan panic-control:list
```

Detail a Panic Control

```
php artisan panic-control:show panic-control-name
```

Activate a Panic Control [1](#user-content-fn-1-e9c1771cf2a453992077ed6a256f2247)

```
php artisan panic-control:active panic-control-name
```

Deactivate a Panic Control [1](#user-content-fn-1-e9c1771cf2a453992077ed6a256f2247)

```
php artisan panic-control:desactive panic-control-name
```

Rules
-----

[](#rules)

We can add supplementary rules that will respect the main status

> All rules must return true for the panic to be activated, if nothing is registered or return null|false, it is disregarded.

### Route Name

[](#route-name)

Checks whether the `Route::currentRouteName()` return is listed inside the `route-name` key.

```
use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'route-name' => [
            'route.name.home',
            'route.name.contact'
        ],
    ],
]);
```

### URL Path

[](#url-path)

Checks whether the `Request::path()` return is listed the `url-path` key.

```
use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'url-path' => [
            'url/path/home',
            'url/path/contact'
        ],
    ],
]);
```

### Sampling

[](#sampling)

Will be activated for just a sample of the users, based on the number of chances, and the "out of" sample. In the example below, the panic control will be activated for 5 out of 10 users i.e. half of the users.

> IMPORTANT: the chance is a probability, there may be a small variation both for more and for less.

```
use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'rules' => [
            'sampling' => [
                'chance' => 5,
                'out_of' => 10,
            ],
        ],
    ],
]);
```

### User logged

[](#user-logged)

Check if user logged `id` or `email` is listed the `user` key.

```
use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'rules' => [
            'user' => [
                1, //User ID
                'user@test.com', //User EMAIL
            ],
        ],
    ],
]);
```

### Custom Rules

[](#custom-rules)

To create a custom rule follow the example

```
use PanicControl\Rules\Rule;
use PanicControl\Contracts\RuleContract;

class ClassName extends Rule implements RuleContract
{
    public function rule(array $parameters): bool|null
    {
        return false|true|null;
    }
}
```

The class must be registered in `config/panic-control.php` under the `rules` key.

```
return [
    ...
    'rules' => [
        'class-name' => Namespace/ClassName::class,
    ],
];
```

In the `rules` column of the database, add the key registered in `config/panic-control.php` with the parameters that will be sent to the class.

```
use PanicControl\Facades\PanicControl;

PanicControl::create([
    'name' => 'panic-control-name',
    'description' => 'Description for Panic Control',
    'status' => true,
    'rules' => [
        'class-name' => 'parameters',
    ],
]);
```

Drivers
-------

[](#drivers)

By default, the driver configured in `config('panic-control.default')`, but can be changed with support for: **database**, **file**, **endpoint**.

```
use PanicControl\Facades\PanicControl;

PanicControl::driver('file')->count()
```

### Extending Driver

[](#extending-driver)

> This feature is in beta tests

If you want to include support for other driver, you can easily register a new driver in the `AppServiceProvider` as shown below:

```
use PanicControl\Facades\PanicControl;

PanicControl::extend('other', function(){
  return return new OtherDrive();
});
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Alexssander Cusin](https://github.com/alexssander-cusin)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Footnotes
---------

1. Not supported for *endpoint store*. [↩](#user-content-fnref-1-e9c1771cf2a453992077ed6a256f2247) [↩2](#user-content-fnref-1-2-e9c1771cf2a453992077ed6a256f2247) [↩3](#user-content-fnref-1-3-e9c1771cf2a453992077ed6a256f2247) [↩4](#user-content-fnref-1-4-e9c1771cf2a453992077ed6a256f2247)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% 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 ~55 days

Recently: every ~63 days

Total

7

Last Release

752d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4c88013d7b954ce468116f6d33f21243e92a8108ddacb83579ed7d9bd619338?d=identicon)[alexssander-cusin](/maintainers/alexssander-cusin)

---

Top Contributors

[![alexssander-cusin](https://avatars.githubusercontent.com/u/1786322?v=4)](https://github.com/alexssander-cusin "alexssander-cusin (138 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")

---

Tags

laravelalexssander-cusinpanic-control-laravel

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alexssander-cusin-panic-control-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/alexssander-cusin-panic-control-laravel/health.svg)](https://phpackages.com/packages/alexssander-cusin-panic-control-laravel)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[maestroerror/laragent

Power of AI Agents in your Laravel project

630106.4k](/packages/maestroerror-laragent)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[spatie/laravel-rdap

Perform RDAP queries in a Laravel app

72108.3k2](/packages/spatie-laravel-rdap)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)

PHPackages © 2026

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