Download the PHP package enea/laravel-authorization without Composer

On this page you can find all versions of the php package enea/laravel-authorization. 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 laravel-authorization

Laravel Authorization

Build Status Scrutinizer Code Quality

Laravel Authorization is a package that provides a simple administration interface for roles and permissions.

Table of Contents

Installation

Laravel Authorization requires PHP 8.1. This version supports Laravel 10 only.

To get the latest version, simply require the project using Composer:

Once installed, if you are not using automatic package discovery, then you need to register the Enea\Authorization\AuthorizationServiceProvider service provider in your config/app.php.

and finally, it only remains to run in the console:

Quick Start

Starting with laravel-authorization is as simple as extending the User model that provides the package:

Or in case you need to customize your user model, you must implement the Enea\Authorization\Contracts\Authorisable interface and use the Enea\Authorization\Traits\Authorisable trait:

Checks

There are some methods available for checking roles and permissions:

Method Parameter Return
can permission-name boolean
cannot permission-name boolean
isMemberOf role-name boolean
isntMemberOf role-name boolean

Example

On the other hand, a role can only have permissions:

GRANT

Simplify the way in which roles and permissions are granted, both can be granted through the grant method in your model, you can see an example here

REVOKE

To revoke a permission or role of a model, you must use the revoke or revokeMultiple method:

DENY

To prohibit certain accesses to a user can do it through the method deny and denyMultiple:

Middleware

The middleware are activated automatically from the beginning, to change this you can do it from the configuration file:

Or in case you want to do a manual configuration you can deactivate the automatic load and modify your kernel file:

Then you can use it in your routes like any other middleware:

In case any user tries to access a protected route without authorization, an exception of type UnauthorizedOwnerException will be throw.

Custom errors

To show a custom error, we can edit the Handler file:

Blade Directives

This package also adds Blade directives to verify if the currently connected user has a specific role or permission. Optionally you can pass in the guard that the check will be performed on as a second argument.

For Roles

and to deny

For Permissions

and to deny

Examples

Simple CRUD

Changelog

Please see CHANGELOG for more information what has changed recently.

License

Laravel Authorization is licensed under The MIT License (MIT).


All versions of laravel-authorization with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^v10.48.18
psr/log Version ^3.0
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 enea/laravel-authorization contains the following files

Loading the files please wait ....