sambindoff/laravel-gust

Laravel Gust is a backend agnostic VueJS authentication frontend for Laravel.

v1.2.0 2022-03-26 08:36 UTC

This package is auto-updated.

Last update: 2024-11-09 23:33:25 UTC


README

Latest Version on Packagist Total Downloads License Buy us a tree

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/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 to app/Models/User.php.
  • Copy the routes/api.php and routes/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 in app/Providers/AuthServiceProvider.php as recommended here, due to the GET route definition no longer existing in a SPA.
  • Change route('login') with url('login') in app/Http/Middleware/Authenticate.php due to the GET route definition no longer existing in a SPA.

What the Fortify stack does

  • Composer require the laravel/fortify package.
  • Run the Fortify vendor:publish command.
  • Add the FortifyServiceProvider to the providers key in config/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 the CreateNewUser and ResetUserPassword 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.

What the Breeze stack does

  • Run the Breeze vendor:publish command.
  • Copy the routes/auth-breeze.php stubs to routes/auth.php and require it in routes/web.php.
  • Copy the app/Http/Controllers/Auth/NewPasswordController.php stub. This ensures a validation exception is thrown for a mismatching token, and also changes route('login') with to('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.

What the UI stack does

  • Composer require the laravel/ui package.
  • Run the ui:controllers command.
  • Copy the routes/auth-ui.php stubs to routes/auth.php and require it in routes/web.php.
  • Copy the app/Http/Controllers/Auth/LoginController.php stub. This overrides the logout 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.

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

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.