Auth Component extends the functionality of Illuminate\Auth
with the extra functionality to retrieve users' role. This is important when we want to manage application Access Control List (ACL).
Laravel | Auth |
---|---|
4.0.x | 2.0.x |
4.1.x | 2.1.x |
4.2.x | 2.2.x |
5.0.x | 3.0.x |
5.1.x | 3.1.x |
5.2.x | 3.2.x@dev |
5.3.x | 3.3.x@dev |
To install through composer, simply put the following in your composer.json
file:
{
"require": {
"orchestra/auth": "~3.0"
}
}
And then run composer install
from the terminal.
Above installation can also be simplify by using the following command:
composer require "orchestra/auth=~3.0"
Next replace Illuminate\Auth\AuthServiceProvider
with the following service provider in config/app.php
.
'providers' => [
// ...
Orchestra\Auth\AuthServiceProvider::class,
Orchestra\Authorization\AuthorizationServiceProvider::class,
Orchestra\Memory\MemoryServiceProvider::class,
Orchestra\Auth\CommandServiceProvider::class,
Orchestra\Memory\CommandServiceProvider::class,
],
CommandServiceProvider
are optional, useful for interaction using the Artisan command line tool.
To make development easier, you could add Orchestra\Support\Facades\ACL
alias for easier reference:
'aliases' => [
'ACL' => Orchestra\Support\Facades\ACL::class,
],