PHPackages                             sonleu/barrier - 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. sonleu/barrier

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

sonleu/barrier
==============

This is a small package to handle pre-conditions in controllers

v1.0.0(5y ago)25MITPHP

Since Sep 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/boyvn2911/barrier)[ Packagist](https://packagist.org/packages/sonleu/barrier)[ RSS](/packages/sonleu-barrier/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Laravel Barrier
===============

[](#laravel-barrier)

This package is used for handling pre-conditions before implementing any job in controller, along with built-in Middleware and Form Request of Laravel.

[![Latest Stable Version](https://camo.githubusercontent.com/24999c6dec1a604eb3303a2f6d222c2c68403a0718ec3f941927851423e72a93/68747470733a2f2f706f7365722e707567782e6f72672f736f6e6c65752f626172726965722f76)](//packagist.org/packages/sonleu/barrier)[![Total Downloads](https://camo.githubusercontent.com/516c549f7b6ce28320c93875e48571cbabfdd51b632b66960c2a29f2af7baf17/68747470733a2f2f706f7365722e707567782e6f72672f736f6e6c65752f626172726965722f646f776e6c6f616473)](//packagist.org/packages/sonleu/barrier)[![Latest Unstable Version](https://camo.githubusercontent.com/904fc5f7fff876e630fd7bc443ceeef2c0351e182413e5558dbde4548cd6e996/68747470733a2f2f706f7365722e707567782e6f72672f736f6e6c65752f626172726965722f762f756e737461626c65)](//packagist.org/packages/sonleu/barrier)[![License](https://camo.githubusercontent.com/9795481ebfcb3885aa777258b14e30f2142cc9dad0f73a7229952d3026f4aaaf/68747470733a2f2f706f7365722e707567782e6f72672f736f6e6c65752f626172726965722f6c6963656e7365)](//packagist.org/packages/sonleu/barrier)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)

    - [Composer](#composer)
- [Usage](#usage)

    - [Generators](#generators)
    - [Use methods](#use-methods)

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

[](#installation)

### Composer

[](#composer)

Execute the following command to get the latest version of the package:

```
composer require sonleu/barrier

```

Usage
-----

[](#usage)

### Generators

[](#generators)

Create your barriers easily through the generator.

#### Commands

[](#commands)

```
php artisan make:barrier MyBarrier

```

This will create a Barrier file inside App/Barriers folder.

#### Example

[](#example)

```
namespace App\Barriers;

use SonLeu\Barrier\BarrierInterface;

class FooBarrier implements BarrierInterface
{
    protected $argument;

    // You can pass any argument here
    public function __construct ($argument)
    {
        $this->argument = $argument;
    }

    /**
     * @return bool
     */
    public function passes(): bool
    {
        if (SOMETHING_SHOULD_NOT_BE_ALLOWED) {
            return false;
        }

        return true;
    }

    /**
     * @return string
     */
    public function message(): string
    {
        return 'Your message if not pass';
    }
}
```

### Use methods

[](#use-methods)

You can use Barriers anywhere inside your controller or even in your business logic layers.

It should be put above your logic.

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use SonLeu\Barrier\HasBarrier;
use SonLeu\Barrier\Exceptions\BarrierNotPassedException;

class FooController extends Controller
{
    use HasBarrier;

    public function bar(Request $request)
    {
        try {
            $this->barrier([
                new CheckIfTuesdayBarrier(),
                new CheckVirginityBarrier(auth()->user()),
            ]);
        } catch (BarrierNotPassedException $e) {
            return back()->with('error', $e->getMessage());
        }

        //TODO: your logic
    }
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

2076d ago

### Community

Maintainers

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

---

Top Contributors

[![boyvn2911](https://avatars.githubusercontent.com/u/37967607?v=4)](https://github.com/boyvn2911 "boyvn2911 (2 commits)")

---

Tags

sonleubarrier

### Embed Badge

![Health badge](/badges/sonleu-barrier/health.svg)

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

PHPackages © 2026

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