Monday, October 5, 2020

Laravel 8 Auth (Registration and Login)

 

Laravel 8 Auth (Registration and Login)





Previously, in Laravel 7 and Laravel 6 in other to do user authentication, we use an artisan command composer require laravel/ui while from Laravel 5.9 downwards uses php artisan make:auth

In Laravel 8, there is a major change in that area in the sense that many things are introduced and a lot of configurations have been done to get you started and not minding the boilerplate of your application, one of those changes is the introduction of Jetstream, Laravel Jetstream is a beautifully designed application scaffolding for Laravel. A major shift from the legacy authentication UI of Laravel.

Step 1: Install a new Laravel app

composer create-project laravel/laravel projectapp --prefer-dist

The command above only install Laravel, however, if you want to install Jetstream together then either


Laravel new projectapp --jet

or

composer require laravel/jetstream

we are going with the first of only installing Laravel, I want to explain other things in the process.

Before we migrate, let’s catch one bug before it throws an error, go to App/Providers/AppServiceProvider.php
and add

Schema::defaultstringLength(191);

to the boot function, also add

use Illuminate\Support\Facades\Schema;

to the top

Step 3: Migration

php artisan migrate

migration file

Step 4: install Jetstream

composer require laravel/jetstream


Step 5: Install livewire or inertia

We need to install one of the stacks, either a livewire or an inertia stack, in this tutorial, I will only be using livewire because it set up everything I need for the app

php artisan jetstream:install livewire 


As suggested, run npm install && npm run dev to build all the javaScript files and CSS we need for our app. On successful build, Laravel will send a notification at the bottom left.


Step 5: Migrate the new table that is created

php artisan migrate


Let’s run our app

php artisan serve 

GitHub repository using Git Bash command

  To add a project to a GitHub repository using Git Bash command line, you can follow these steps: Create a new repository on GitHub by logg...