Download the PHP package machuga/authority-l4 without Composer
On this page you can find all versions of the php package machuga/authority-l4. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download machuga/authority-l4
More information about machuga/authority-l4
Files in machuga/authority-l4
Package authority-l4
Short Description A simple and flexible authorization system for PHP
License
Homepage https://github.com/machuga/authority-l4
Informations about the package authority-l4
THIS REPO IS DEPRECATED
I no longer use PHP enough to be able to work on Authority so it's time to EOL it. If you're interested in taking it over, ping me in an issue with "@machuga".
Authority-L4
A simple and flexible authorization system for Laravel 4
Installation via Composer
Add Authority to your composer.json file to require Authority
require : {
"laravel/framework": "~4",
"machuga/authority-l4" : "dev-master"
}
Now update Composer
composer update
The last required step is to add the service provider to app/config/app.php
Congratulations, you have successfully installed Authority. However, we have also included some other configuration options for your convenience.
Additional (optional) Configuration Options
Add the alias (facade) to your Laravel app config file.
This will allow you to access the Authority class through the static interface you are used to with Laravel components.
Publish the Authority default configuration file
This will place a copy of the configuration file at app/config/packages/machuga/authority-l4
. The config file includes an 'initialize' function, which is a great place to setup your rules and aliases.
Create Roles and Permissions Tables
We have provided a basic table structure to get you started in creating your roles and permissions.
Run the Authority migrations
This will create the following tables
- roles
- role_user
- permissions
To utilize these tables, you can add the following methods to your User
model. You will also need to create Role and Permission Model stubs.
Lastly, in your Authority config file which you copied over in the previous configuration step. You can add some rules:
General Usage
Interface
There are 5 basic functions that you need to be aware of to utilize Authority.
-
allow: create a rule that will allow access a resource
example 1:
example 2, using an extra condition:
-
deny: create a rule that will deny access a resource
example 1:
example 2, using an extra condition:
-
can: check if a user can access a resource
example:
-
cannot: check if a use cannot access a resource
example:
-
addAlias: alias together a group of actions
this example aliases together the CRUD methods under a name of
manage
Converting to this library, where you previously had been using the IoC container to resolve an instance.
The service provider will merely create a new instance of Authority, and pass in the currently logged in user to the constructor. This should be basically the same process that you were doing in your IoC registry. This means that any code you have used in the past should still work just fine! However it is recommended that you move your rule definitions into the provided configuration file.