PHPackages                             rookwood/turnstile - 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. rookwood/turnstile

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

rookwood/turnstile
==================

Policy-based ACL for Laravel 4.x

v0.1.0(11y ago)517MITPHPPHP &gt;=5.4.0

Since Jul 13Pushed 11y ago1 watchersCompare

[ Source](https://github.com/rookwood/turnstile)[ Packagist](https://packagist.org/packages/rookwood/turnstile)[ RSS](/packages/rookwood-turnstile/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Turnstile
=========

[](#turnstile)

Turnstile is a policy-based ACL library for Laravel 4 designed to give very fine-grained control over user permissions. This is accomplished by mapping any given user action to a policy class that evaluates if the action is allowable. Doing such allows for more control than a simple user/role system (though roles are still easily used in Turnstile). The beauty of this is that the same system can be used for everything from protecting an admin panel to checking if a user can see a login button (if already logged in, just deny access for visibility, etc).

### Example

[](#example)

Since no one has ever used a blog example before, we'll do that here:

```
// CommentController.php (or somesuch)
if ($this->user->can("edit_comment", ['comment' => $comment]))
{
    // logic
}
else
{
    // pass back an error telling them why they were denied
}
```

The `edit_comment` action is mapped to a policy class via a `PolicyProvider`. For `edit_comment`, we map to `CommentEditingPolicy` for this example.

```
