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.
You can install the package via composer:
composer require y0rdie/laravel-gust --dev
Gust offers a choice of three backend stacks: Fortify, Breeze or UI (for you dinosaurs among us).
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.
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.
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.
php artisan migrate
npm install && npm run dev
In order for any SPA to be compatible with Laravel, here is an exhaustive list of all the changes required:
- Composer require the
laravel/sanctum
package. - Run the Sanctum
vendor:publish
command. - Add
SANCTUM_STATEFUL_DOMAINS
as an environment variable. - Add the Sanctum middleware to
app/Http/Kernel.php
. - Add the
MustVerifyEmail
interface toapp/Models/User.php
. - Copy the
routes/api.php
androutes/web.php
stubs. - Delete the
resources/sass
directory. - Delete the
resources/js/bootstrap.js
file. - Delete the
resources/views
directory ready for the new stubs. - Publish all the SPA stubs.
- Update
package.json
to require Vue.js, Vue Router, Vuex and Tailwind CSS. - Customise the password reset link URL using the
ResetPassword::createUrlUsing
method inapp/Providers/AuthServiceProvider.php
as recommended here, due to the GET route definition no longer existing in a SPA. - Change
route('login')
withurl('login')
inapp/Http/Middleware/Authenticate.php
due to the GET route definition no longer existing in a SPA.
- Composer require the
laravel/fortify
package. - Run the Fortify
vendor:publish
command. - Add the
FortifyServiceProvider
to the providers key inconfig/app.php
. - Update
config/fortify.php
to set'views' => false,
and only enable the registration, reset passwords, email verification features. - Update
app/Providers/FortifyServiceProvider.php
to only register theCreateNewUser
andResetUserPassword
actions. - Delete the
app/Actions/Fortify/UpdateUserPassword.php
file. - Delete the
app/Actions/Fortify/UpdateUserProfileInformation.php
file.
You can find out more about Laravel Fortify in the official repository.
- Run the Breeze
vendor:publish
command. - Copy the
routes/auth-breeze.php
stubs toroutes/auth.php
and require it inroutes/web.php
. - Copy the
app/Http/Controllers/Auth/NewPasswordController.php
stub. 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/Views
directory.
You can find out more about Laravel Breeze in the official repository.
- Composer require the
laravel/ui
package. - Run the
ui:controllers
command. - Copy the
routes/auth-ui.php
stubs toroutes/auth.php
and require it inroutes/web.php
. - Copy the
app/Http/Controllers/Auth/LoginController.php
stub. This overrides thelogout
method to explicitally use the auth web guard. - Delete the
app/Http/Controllers/HomeController.php
file.
You can find out more about Laravel UI in the official repository.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
- Loris Leiva - Unlock your frontend skills
- Markus Oberlehner - Implementing a Simple Middleware with Vue Router
- All Contributors
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.