Download the PHP package curlymoustache/sanction without Composer

On this page you can find all versions of the php package curlymoustache/sanction. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sanction

Sanction.

Note: Requires PHP5.4+

Yep, another access control package for PHP, including some neat integration with Laravel 4.

Declare a list of roles, the permissions they can access, and any other roles they inherit from as a config array (or file, or whatever you like!), then let Sanction do the rest.

Attaching roles to users is your job, this merely sets what they can do once they're attached - But we provide some helpers for Laravel (and hopefully some more generic stuff soon too).

Basic Usage

Let's say we have a user management app, with two roles defined, standard_user, and admin. Our standard_user can create and update users, but our administrator_user can also delete users, as well as creating and updating them.

Apply these rules to an instance of Sanction:

Features

Swappable integrations.

Thanks to lovely the wonder of PHP interface, you can swap out the implementations of the Cache and RoleLookup parts of your application, meaning that this could potentially be used with any framework or CMS.

Cache Providers

To adjust Sanction to work with other frameworks or even just plain ol' PHP, you can create your own CacheProvider by implementing Curlymoustache\Sanction\Cache\SanctionCacheProviderInterface and ensuring it returns the right stuff.

You can then set this as a new provider by calling $sanction->setCacheProvider(new MyCustomCacheProvider);

Role Lookup Providers

If you wish to change how Sanction looks for roles against users, you will need to implement a RoleLookupProvider, which you can do by creating a class that implements Curlymoustache\Sanction\RoleLookup\SanctionRoleLookupProviderInterface.

You can then set this as a new provider by calling $sanction->setRoleLookupProvider(new MyCustomLookupProvider);

Installation

Installation is done via Composer, simply add this line to your composer.json file (PS - versioned release coming soon!):

Then run $ composer update or $ composer install on the command line (if you have composer installed).

Don't have composer installed?

You can download a copy of composer to your working directory by typing:

Then you can run composer commands by using:

If you want to make the copy of composer 'global', then you can move the file to somewhere in your $PATH, like /usr/local/bin:

Getting Started Using Laravel 4

Sanction and Laravel 4 are the best of friends! Add the following to your app/config/app.php file, at the end of the $providers array:

Then add the following alias to the $aliases array:

This will make calls to Sanction::methodName() possible.

Publish the config files

Now publish the config files, this is needed:

You should now be able to open app/config/packages/curlymoustache/sanction/roles.php and app/config/packages/curlymoustache/sanction/config.php.

There! Now you can add your role definitions into the roles.php config file.

Run the migration

Run the migration from the package, this will install a roles table into your database, allowing you to persist role information for users.

Simply run:

Eloquent Extension

Are you using the default Eloquent user model? Good news then! There's a PHP Trait that you can include into your User model to enable some shortcuts.

Just use the trait in your User model:

This will allow to use the following methods:

MethodDescription
User::usersWithRole($role_name)Return an eloquent collection of users with a particular role.
$user->addRole($role_name)Add a role to the current instance of `User`
$user->deleteRole($role_name)Delete a role from the current instance of `User`.
$user->can($permission_names)Verify a user has a permission (string) or multiple permissions (array).
$user->is($role_name)Returns true if the user has the role supplied.
$user->getRoles()Returns the list of roles associated with the user, if any.
$user->getPermissions()Returns the list of permissions associated with the user, if any.

Remember that to use this extension, your model must extend the Eloquent class, and be using id as the primary key.

Clear the permissions cache with Artisan

When you update app/config/packages/curlymoustache/sanction/roles.php with caching enabled in the config file, you will need to clear the permissions cache for your new rules to take effect.

Sanction provides a handy artisan command to do so, this will call the delete method on whatever cache_provider you have setup in config.php.

Or if you want to do it in your code somewhere, call:

More coming soon, stay tuned


All versions of sanction with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 4.0.*
zendframework/zend-permissions-acl Version 2.2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package curlymoustache/sanction contains the following files

Loading the files please wait ....