PHPackages                             wishfoundry/authorize - 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. wishfoundry/authorize

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

wishfoundry/authorize
=====================

An Authentication and Authorization package for Laravel 4

81243[1 issues](https://github.com/wishfoundry/Authorize/issues)PHP

Since Apr 10Pushed 13y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Authorize
=========

[](#authorize)

Authorize is a port of the well known Authority library Matthew Machuga and Jesse O'brien, to Laravel 4. Most of the functions are similar with some enhancements. This library patches the system Auth class with super powers, and is meant to verify the authentication as well as the authority of the current system user.

!docs Authorize

Rommie: Would you like some docs?

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

[](#installation)

This package depends on php5.4 advanced closures. php5.3 is not supported nor will be. to install add the package dependancy to your composer json file:

```
"wishfoundry/authorize": "dev-master"

```

and in your app/config/app.php file replace the default auth service provider

```
#'Illuminate\Auth\AuthServiceProvider',
'Wishfoundry\Authorize\AuthorizeServiceProvider',
```

Migrations
----------

[](#migrations)

An example migration is provide in src/migrations but is not required. Please customize to suit your needs An matching example trait is provided for you to use in your User models as well. Simply include with

```
class User {
....
use Wishfoundry\Authorize\AuthorizeUserRoleTrait;
}

```

or customize to suit your needs.

Rules
-----

[](#rules)

Authorize does not come with and rules loaded by default. Rules can be added dynamically at any time, thus saving needless calls to the database. The recommended method of adding rules is to set up a route filter:

In a global filter you could setup some basic aliases

```
App::before(function($request)
{
	Auth::addAlias('Administrate', ['create', 'view', 'modify', 'delete', 'flag', 'unflag']);
	Auth::addAlias('Moderate',     ['view', 'delete', 'flag', 'unflag']);
	Auth::addAlias('AllButView',   ['create', 'modify', 'delete', 'flag', 'unflag']);
});
```

Then you can define your rules in a named filter

```
Route::filter('admin', function()
{
	if (Auth::guest())
	{
	    Auth::deny('AllButView', ['Post', 'Comment']);

	    /**
	     * Rule actions can be any arbitrary string you decide
	     * except for the reserved word all, which is defined internally
	     */
	    Auth::deny('all', 'User');
	}

    // Only make a DB call if user is logged in
	elseif (Auth::user()->hasRole('admin) )
	{
	    Auth::allow('Administrate', ['User', 'Post', 'Comment']);
	}
});
```

Usage is simple and elegant

```
if(Auth::can('delete', 'User')
{
    $user->delete()
}
...
if( Auth::cannot('view', 'Comment') )
{
    return Redirect::to('unauthorized');
}
// Or by aliases
if(Auth::can('Administrate', 'Post')) ...
```

for more advanced useage, Closures can be supplied:

```
Auth::allow('delete', 'Post')->when(function($post){
    return $this->user()->id == $post->user_id;
});
```

Which passed a variable as:

```
if( Auth::can('delete', 'Post', $post) )
{
    $post->delete();
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a6a55f415eed8bd2f959d45993f18bfdae91cf428c972d6ebd3479de92298d8?d=identicon)[wishfoundry](/maintainers/wishfoundry)

---

Top Contributors

[![wishfoundry](https://avatars.githubusercontent.com/u/818080?v=4)](https://github.com/wishfoundry "wishfoundry (16 commits)")[![iccle](https://avatars.githubusercontent.com/u/518938?v=4)](https://github.com/iccle "iccle (5 commits)")

### Embed Badge

![Health badge](/badges/wishfoundry-authorize/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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