Download the PHP package nh/access-control without Composer

On this page you can find all versions of the php package nh/access-control. 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 access-control

Installation

Install the package via composer:

Publish the databases and the models for the roles:

To make a model with role, you can create a migration via the console commande: The --many option will create a roleables table with many to many morph relationship

Then, if your model is has only one role add the HasAccess trait to your model:

Create permission

You can create permission via the console commande: You can create a single permission, or all action permissions for a model.

Check the access

Check if a model has any role :

Check if a model has some roles : You must pass a string or an array By default it will check on the guard column, but you can specify the column

Check if a model has some permissions : You must pass a string or an array

Check if a model has access to a model/action : You must pass a string for the model and a string or an array for the actions

Check if a model has superpower : You can change the superpowers role in the config file

Scope the model with role(s) :

Models

The package come with two models:

Role

The role have a guard and name attribute.

You can retrieve the restricted permissions:

You can also retrieve the restricted permissions from a model with multiple roles:

You can check if a role have a permission: $permissions can be a string or an array

You can check if a role have a permission by model/action: $actions can be a string or an array $strict must be a boolean, and check if AS ANY or AS ALL permission

Events

You can use the RoleEvent for dispatch events that happen to the role access.

You can use the PermissionEvent for dispatch events that happen to the role/permission access.

Gates

You can use the set-roles Gate to check if current Auth can set the roles. $roles must be an array of ids In the config file you can specify the roles that are guarded and required an Auth of the same role

You can use the set-permissions Gate to check if current Auth can set the permission for a role. $permissions must be an array of ids In the config file you can specify the roles that are guarded and required an Auth of the same role


All versions of access-control with dependencies

PHP Build Version
Package Version
No informations.
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 nh/access-control contains the following files

Loading the files please wait ....