Download the PHP package alleyinteractive/simple-laravel-roles without Composer

On this page you can find all versions of the php package alleyinteractive/simple-laravel-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 simple-laravel-roles

Simple Laravel Roles

This package adds very simple role/capability functionality to a Laravel application, where the roles and capabilities are defined using a config file.

Once roles and capabilities are defined and a role is assigned to a user, capabilities can be checked using Laravel's built-in authorization functionality:

Installation

Via Composer

Setup and Configuration

  1. Once the package is installed, you can publish the package files using artisan:

    This will add two files to your application:

    • config/roles.php is where you'll define your roles.
    • database/migrations/<date>_add_roles_to_users_table.php adds a roles column to the users table. Delete this file if it doesn't apply to your use case.
  2. Configure your roles and capabilities in config/roles.php.
  3. Run php artisan migrate if you just need to add roles to the users table. If you want to add roles to more tables, create your migrations first.
  4. Add the Alley\SimpleRoles\HasRoles trait to the User model and/or any models that will have roles.

Usage

In Gates and Policies

This package is intended to augment Laravel's built-in authorization functionality by adding role and capability buckets in which to add users or other models. These buckets can be checked during your Gate or Policy checks.

Here's an example Policy method that leverages capabilities to allow deleting a post if the user owns the post or the user is allowed to delete others' posts:

In place of Gates and Policies

Depending on the complexity of your application, this package could even replace your gate and policy checks. It will intercept all Gate checks before other authorization checks and if the user has the given ability as a capability in any of their roles, the check will pass. With this, Laravel's core authorization functionality will work as usual, and capabilities will be checked instead of defined gates or policies. In other words, if a user has a role with the delete_posts capability, that capability can be checked using:

As well as in blade templates:

The HasRoles trait also includes some helpers to check capabilities and roles:

Further, the package provides a Role class which can be used to check capabilities on a specific role.

Change log

See the changelog.

Testing

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email the author email (found in composer.json) instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.


All versions of simple-laravel-roles with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ~7|~8
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 alleyinteractive/simple-laravel-roles contains the following files

Loading the files please wait ....