sambindoff / laravel-gust
Laravel Gust is a backend agnostic VueJS authentication frontend for Laravel.
Installs: 99
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 3
Forks: 1
Open Issues: 0
Language:Vue
pkg:composer/sambindoff/laravel-gust
Requires
- php: ^8.0
- illuminate/contracts: ^9.0
- laravel/breeze: ^1.0
Requires (Dev)
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.5.10
- sambindoff/php-styles: dev-main
- vimeo/psalm: ^4.0
README
Introduction
Laravel Gust is a backend agnostic Vue.js authentication frontend for Laravel. Gust can power the registration and authentication features of your Laravel backend when using Laravel Fortify, Breeze or UI.
Gust is powered by Vue.js v3, Vue Router v4, Vuex v4 and Tailwind CSS v2 on the frontend and provides scaffolding to get you started with a basic Vue.js SPA that is compatible with all Laravel backend authentication packages.
Gust uses Laravel Sanctum on the backend to authenticate your SPA regardless of the stack you choose.
You can read more about how to install each stack and the changes they make to your application below.
Installation
You can install the package via composer:
composer require y0rdie/laravel-gust --dev
Usage
Gust offers a choice of three backend stacks: Fortify, Breeze or UI (for you dinosaurs among us).
Install with Fortify
The Fortify stack is a good choice if you don't need to customise the backend authentication logic this package provides as this is all handled by the package itself.
php artisan gust:install fortify
Read about the changes this makes to your application in the What the Fortify stack does section below.
Install with Breeze
The Breeze stack is a good choice if you want greater control over the backend authentication logic this package provides as this is all published into your application.
php artisan gust:install breeze
Read about the changes this makes to your application in the What the Breeze stack does section below.
Install with UI
The UI stack is a good choice if you're already familiar with the backend authentication logic this package provides and not quite ready to make the switch to Breeze or Fortify.
php artisan gust:install ui
Read about the changes this makes to your application in the What the UI stack does section below.
Finalising the Installation
php artisan migrate
npm install && npm run dev
What this does to your application
What all stacks do
In order for any SPA to be compatible with Laravel, here is an exhaustive list of all the changes required:
- Composer require the
laravel/sanctumpackage. - Run the Sanctum
vendor:publishcommand. - Add
SANCTUM_STATEFUL_DOMAINSas an environment variable. - Add the Sanctum middleware to
app/Http/Kernel.php. - Add the
MustVerifyEmailinterface toapp/Models/User.php. - Copy the
routes/api.phpandroutes/web.phpstubs. - Delete the
resources/sassdirectory. - Delete the
resources/js/bootstrap.jsfile. - Delete the
resources/viewsdirectory ready for the new stubs. - Publish all the SPA stubs.
- Update
package.jsonto require Vue.js, Vue Router, Vuex and Tailwind CSS. - Customise the password reset link URL using the
ResetPassword::createUrlUsingmethod inapp/Providers/AuthServiceProvider.phpas recommended here, due to the GET route definition no longer existing in a SPA. - Change
route('login')withurl('login')inapp/Http/Middleware/Authenticate.phpdue to the GET route definition no longer existing in a SPA.
What the Fortify stack does
- Composer require the
laravel/fortifypackage. - Run the Fortify
vendor:publishcommand. - Add the
FortifyServiceProviderto the providers key inconfig/app.php. - Update
config/fortify.phpto set'views' => false,and only enable the registration, reset passwords, email verification features. - Update
app/Providers/FortifyServiceProvider.phpto only register theCreateNewUserandResetUserPasswordactions. - Delete the
app/Actions/Fortify/UpdateUserPassword.phpfile. - Delete the
app/Actions/Fortify/UpdateUserProfileInformation.phpfile.
You can find out more about Laravel Fortify in the official repository.
What the Breeze stack does
- Run the Breeze
vendor:publishcommand. - Copy the
routes/auth-breeze.phpstubs toroutes/auth.phpand require it inroutes/web.php. - Copy the
app/Http/Controllers/Auth/NewPasswordController.phpstub. This ensures a validation exception is thrown for a mismatching token, and also changesroute('login')withto('login')due to the GET route definition no longer existing in a SPA. - Delete the
app/Viewsdirectory.
You can find out more about Laravel Breeze in the official repository.
What the UI stack does
- Composer require the
laravel/uipackage. - Run the
ui:controllerscommand. - Copy the
routes/auth-ui.phpstubs toroutes/auth.phpand require it inroutes/web.php. - Copy the
app/Http/Controllers/Auth/LoginController.phpstub. This overrides thelogoutmethod to explicitally use the auth web guard. - Delete the
app/Http/Controllers/HomeController.phpfile.
You can find out more about Laravel UI in the official repository.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Loris Leiva - Unlock your frontend skills
- Markus Oberlehner - Implementing a Simple Middleware with Vue Router
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
*This package might have a catchy one word name just like many other first party Laravel packages, however, this is most definitely an unoffical package and in no way endorsed by the Laravel team. It's more of a tongue-in-cheek reference, but hopefully just as brilliant.