Authentication in laravel 6 step-by-step

Laravel makes implementing authentication very simple.

You might have noticed that the make:auth command is no longer exists in laravel 6.

To implement authentication in laravel 6 the laravel/ui package is required.

1) Install the laravel/ui Package

To install laravel/ui package via composer run the following command in your terminal inside your project folder :

composer require laravel/ui

2) Create the auth scaffolding in Laravel

Now if you want to use Vue, React, or Bootstrap in your project, the UI package provides the following commands:

//For bootstrap
php artisan ui bootstrap

//For vue
php artisan ui vue

//For react
php artisan ui react

If you want to generate the auth scaffolding at the same time then use the following commands:

//For bootstrap
php artisan ui bootstrap --auth

//For vue
php artisan ui vue --auth

//For react
php artisan ui react --auth

If you don’t want to use vue or react in your project then just run the following command to create the auth scaffolding.

php artisan ui:auth

ui:auth command will generate the following things for us:

  • Auth routes
  • HomeController
  • Auth views
  • app.blade.php layout file

By running ui:auth command the auth scaffolding will be created but views will not have styling. So we have to install frontend dependencies using the following commands :

npm install
npm run dev

Now, you can run your project using php artisan serve command and go to http://127.0.0.1:8000/ to see that authentication is created.

Hope it helps, happy coding!

Install the laravel/ui package

Create the auth scaffolding.

Leave a Reply

avatar
  Subscribe  
Notify of