Download the PHP package alexya-framework/roles without Composer

On this page you can find all versions of the php package alexya-framework/roles. 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 roles

Roles

Alexya's Role Based Access System utilities.

Contents

Creating permissions

Permissions are the way to authorized users to perform certain actions.

The class \Alexya\Roles\Permission represents a permission that can be assigned to a specific role.

A permission consists of an identifier, a title and a status flag.

You can easily extend this class to provide more functionality such as alternative names, ranks...

For example, in a file system, each user should have permissions to read/write to certain files:

Creating roles

Roles are the containers of various permissions.

The class \Alexya\Roles\Role represents a role by itself.

It has an identifier for the role, a title and an array of Permission with the granted permissions for this role. Alternatively, a role can have a parent role for inheritance.

It also has an integer representing the priority of the role, the bigger the number, the most priority it has.

The method hasPermission accepts an identifier of a permission or an instance of the permission and checks that this role has been granted with the permission.

For a shorter version, you can use can, 'cuz shorter > longer.

Example:

Adding permissions to roles

Once you have the permissions and roles you need to specify which roles have granted which permissions.

A permission can be enabled, disabled or inherited. If a permission is inherited the role will check the status of that permission in the parent role, if there's no parent role it will be treated as disabled.

Adding permissions to roles is as easy as calling the addPermission method with the permission to add.

Example:

To check if a role has granted a certain permission you can use the hasPermission or can methods:

The method getPermission returns a permission from the role:

Creating users

Now that we have the roles and permissions we need users to assign them.

The class \Alexya\Roles\User represents an user, where the roles are assigned.

It's the class that you should extend in order to add roles to your users as it provides the hasPermission and can methods for checking if this user has any permission granted.

It also has the methods addRole and removeRole to add/remove roles.

Example:


All versions of roles with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
alexya-framework/tools Version >=3.2
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 alexya-framework/roles contains the following files

Loading the files please wait ....