Code Monkey home page Code Monkey logo

laravel-gust's Introduction

Laravel Gust*

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.

laravel-gust's People

Contributors

y0rdie avatar

Stargazers

Rifki Aria Gumelar avatar Ben Bjurstrom avatar Ahmad  avatar  avatar Rakan avatar Principal Coder avatar Mihai Solomon avatar Wyatt Castaneda avatar Loris Leiva avatar  avatar Davor Minchorov avatar Jorge avatar BKF avatar Sam Parton avatar Kevin Jiang avatar Flávio H. Ferreira avatar Andrea Sangiorgio avatar  avatar  avatar

Watchers

Massimo Simonini avatar  avatar Rauf Abbas avatar

Forkers

lovecoding-git

laravel-gust's Issues

UI stack should add package to project

Due to the UI package containing files/traits used by the controllers, this package needs requiring in the projects composer file just like the fortify stack does. The Gust scaffold package can then be removed safely.

PHP version

Can't install on Laravel 8 because this package require PHP-7.4, but Laravel 8 has PHP-7.3.
Are there any dependencies preventing you from setting a minor PHP version?

    "require": {
        "php": "^7.3|^8.0",
        "illuminate/contracts": "^8.0",

Unit Tests

Hey Sam!

Thanks for submitting this piece of work to the Laravel community. I would recommend to introduce some unit tests and do some separation of concerns: perhaps the InstallCommand does too much. This package may require changes if any stack changes (fortify, breeze, or ui), so tests will help you a lot to track these issues.

Best of luck!

Vue 3

This will be implemented when the Vue.js team are fully supporting Vue 3 with Vue Router 4 and Vuex 4, as outlined in the Vue docs

If I've missed this and it's already fully supported please @ me with some examples and I'll implement, or feel free to submit a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.