Laravel Auth is a collection of reusable modules to build your own laravel authentication comfortably. It comfortably integrates into any Laravel application with 1 line of code. This package is what laravel/ui
should have been and laravel/fortify
have not became.
Yes. The goal of this package is to have a built in modular Laravel authentication and keep flexibility without configuring an additional packages.
Only Laravel +5.5
supported by the library. You can istall package using composer:
composer require westacks/laravel-auth
The package will self-register it's ServiceProvider using Laravel's auto-discovery. If you turned off auto-discovery for some reason, you need to register service provider manually in config/app.php
:
'providers' => [
/*
* Package Service Providers...
*/
WeStacks\Laravel\Auth\Providers\AuthServiceProvider::class,
],
If you need just basic auth, you only need to define controller routes in your routes/web.php
file:
# routes/web.php
<?php
use Illuminate\Support\Facades\Route;
Route::auth();
Publish all views to your resource\views
directory using command:
php artisan vendor:publish --provider="WeStacks\Laravel\Auth\Providers\AuthServiceProvider"
If you want completely remove auth views from application, just initialize routes without them:
# routes/web.php
<?php
use Illuminate\Support\Facades\Route;
Route::auth([
'views' => false
]);
You may define custom pathes to your views using this config to:
# routes/web.php
<?php
use Illuminate\Support\Facades\Route;
Route::auth([
'login_view' => 'auth::login',
'register_view' => 'auth::register',
'reset_password_view' => 'auth::password.reset',
'forgot_password_view' => 'auth::password.forgot',
'confirm_password_view' => 'auth::password.confirm',
'verify_view' => 'auth::verify',
]);
Just define only features you want to use and you are ready to go:
# routes/web.php
<?php
use Illuminate\Support\Facades\Route;
Route::auth([
'login' => true,
'logout' => true,
'register' => true,
'reset' => true,
'confirm' => false,
'verify' => false,
]);
If you want to customize auth controller methods, you need to extend your own controller from library's AuthController
:
php artisan make:controller AuthController
# routes/web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
Route::auth([
'controller' => AuthController::class,
'middleware' => 'auth' // if you using custom guards for authenticated routes, put them here
]);
# app/Http/Controllers/AuthController.php
<?php
namespace App\Http\Controllers;
use WeStacks\Laravel\Auth\Controllers\AuthController as Controller;
class AuthController extends Controller
{
// Your customs here
}
Check WeStacks\Laravel\Auth\Traits
namespace for customizing logic of your auth backend.
- Initial release
- Make library work
larave/ui
-like. - Make controller syntax cleater.