PHPackages                             maximkou/laravel-simple-voters - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. maximkou/laravel-simple-voters

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

maximkou/laravel-simple-voters
==============================

Symfony-like voters system to check row based access.

0.2(8y ago)371MITPHPPHP &gt;=7.0

Since May 12Pushed 8y ago3 watchersCompare

[ Source](https://github.com/maximkou/laravel-simple-voters)[ Packagist](https://packagist.org/packages/maximkou/laravel-simple-voters)[ RSS](/packages/maximkou-laravel-simple-voters/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (3)Used By (0)

Laravel 5 Voters System
=======================

[](#laravel-5-voters-system)

[![Latest Stable Version](https://camo.githubusercontent.com/2cc28d30c67ce9b97945a2201d2050e8152b315e912819159b94948c1759e41e/68747470733a2f2f706f7365722e707567782e6f72672f6d6178696d6b6f752f6c61726176656c2d73696d706c652d766f746572732f762f737461626c652e737667)](https://packagist.org/packages/maximkou/laravel-simple-voters)[![License](https://camo.githubusercontent.com/bf767860d1ca14bee09f091d353231bae62f52aeb9fbb08d8a66096ef30f5c22/68747470733a2f2f706f7365722e707567782e6f72672f6d6178696d6b6f752f6c61726176656c2d73696d706c652d766f746572732f6c6963656e73652e737667)](https://packagist.org/packages/maximkou/laravel-simple-voters)

This package provide Symfony Security Voters like system, which allow you to check object-based access.

Using examples
--------------

[](#using-examples)

Check, is current user can edit specific Post:

```
is_granted('edit', $post) // return true or false
// or using Facade
Access::isGranted('edit', $post)
```

Check, is specific user can read or write specific Post info:

```
is_granted(['read', 'write'], $post, $user) // return true or false
// or using Facade
Access::isGranted(['read', 'write'], $post, $user)
```

Installation:
-------------

[](#installation)

Require dependency using composer:

```
composer require maximkou/laravel-simple-voters ^0.1
```

Add service provider to your `config/app.php`:

```
'providers' => [
    Maximkou\SimpleVoters\SimpleVotersServiceProvider::class,
```

Add facade alias to your `config/app.php` (optional):

```
'aliases' => [
    'Access' => Maximkou\SimpleVoters\Facades\Access::class,
```

Publish package config (optional):

```
php artisan vendor:publish --provider="Maximkou\SimpleVoters\SimpleVotersServiceProvider"
```

Configuration:
--------------

[](#configuration)

```
// file config/voters.php
/**
 * Available out of the box strategies: affirmative, unanimous, consensus.
 * You can use custom voting strategy by registering service with name 'simple_voters.strategies.{strategy_name}'
 */
'strategy' => 'unanimous',

/**
 * If pro and contra votes count is equal, or all voters abstain, used this value
 */
'is_granted_by_default' => true,

/**
 * List of Voter classes.
 */
'voters' => [
    // put here your voters classes
],
```

Creating Voter
--------------

[](#creating-voter)

Voter must implement `Maximkou\SimpleVoters\Contracts\Voter` or extend `Maximkou\SimpleVoters\AbstractVoter` class. Then add your voter to config.

Example:

```
class PostVoter extends AbstractVoter
{
    protected function supports($action, $object)
    {
        return in_array('action', ['edit', 'remove']) && $object instanceOf Post;
    }

    protected function isGranted($action, $object, $user)
    {
        $checker = "can".ucfirst($action);

        return $this->$checker($object, $user);
    }

    private function canEdit($object, $user)
    {
        return $object->user_id = $user->id;
    }

    private function canRemove($object, $user)
    {
        return $object->user_id = $user->id;
    }
}
```

Using in non-laravel context
----------------------------

[](#using-in-non-laravel-context)

For using in non-laravel context, you only must create custom `AuthenticatedUserResolver`, for resolving current user instance.

Example:

```
use Maximkou\SimpleVoters\Services\Access;
use Maximkou\SimpleVoters\GrantStrategies;

$accessChecker = new Access(
    new GrantStrategies\Affirmative($listVoters), // choose voting strategy
    new MyAuthUserResolver() // pass your user resolver
);

$accessChecker->isGranted('action', $object); // true/false?

```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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

Every ~3 days

Total

2

Last Release

3283d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2118695?v=4)[Maxim Khodyrev](/maintainers/maximkou)[@maximkou](https://github.com/maximkou)

---

Top Contributors

[![maximkou](https://avatars.githubusercontent.com/u/2118695?v=4)](https://github.com/maximkou "maximkou (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maximkou-laravel-simple-voters/health.svg)

```
[![Health](https://phpackages.com/badges/maximkou-laravel-simple-voters/health.svg)](https://phpackages.com/packages/maximkou-laravel-simple-voters)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[stechstudio/laravel-jwt

Helper package that makes it easy to generate, consume, and protect routes with JWT tokens in Laravel

126117.6k](/packages/stechstudio-laravel-jwt)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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