Laravel 8 - UI Auth
Laravel 8 - UI Auth
In this tutorial, we will discuss how to implement UI Auth in Laravel 8. Laravel UI Auth is a package that provides a simple way to scaffold basic authentication views and routes (such as login, registration, and password reset) for a Laravel project. It is commonly used to quickly set up authentication in Laravel applications.
If you're a video person, feel free to skip the post and check out the video instead!
Quick Overview
In this guide, we’ll walk you through setting up authentication for your fresh Laravel project. First, we’ll create a new Laravel project either using the global Laravel Installer or Composer. After that, we’ll access the project directory through the command line. Then, we’ll install the laravel/ui package, which provides all the necessary authentication views and routes for your project. Next, we'll generate the authentication scaffolding using Vue.js to create the required views, routes, and controllers. We’ll also install the necessary NPM dependencies and compile the frontend assets using Laravel Mix. Once that’s done, we’ll run the database migrations to create the authentication-related tables in your database. Finally, we’ll start the development server and test the authentication system by visiting the registration, login, logout, and password reset routes.
Step # 1 : Create Fresh Laravel Project
Two commands to create fresh Laravel project.
Using the global Laravel Installer, you can quickly create a new Laravel project named auth (requires Laravel Installer to be installed globally).
laravel new auth
Or use
If the Laravel Installer is not installed, use Composer to create a new project named auth.
composer create-project laravel/laravel --prefer-dist auth
Step # 2 : Access the project.
Access the project in the command-line interface (e.g., Git Bash).
cd c:xampp/htdocs/auth
Step # 3 : Install UI Auth.
Below command installs the laravel/ui package, which provides the necessary authentication views and routes for your Laravel project.
composer require laravel/ui
Step # 4 : Generate the UI authentication scaffolding for your Laravel project.
Below command creates the necessary authentication views, routes, and controllers using Vue.js.
php artisan ui vue --auth
Step # 5 : Install the necessary NPM dependencies.
The following command installs the necessary NPM dependencies for your Laravel project.
npm install
Step # 6 : Compile the frontend assets using Laravel Mix.
Compile the frontend assets using Laravel Mix with the following command. If it doesn't work, try npm run development instead.
npm run dev
Step # 7 : Run Migrations.
Laravel UI includes the necessary migrations for the authentication system. Run the following command to create the required tables in your database.
php artisan migrate
Step # 8 : It's time to test.
Start the Laravel development server with the following command.
php artisan serve
Now, you can visit the following routes to use the authentication system:

/register - User registration page
/login - User login page
/logout - User logout
/password/reset - Password reset request page
Conclusion
This guide streamlines the process of adding authentication to a Laravel project. By following these steps, you can quickly integrate essential features like user login, registration, and password resets, ensuring your app is ready for secure user interaction.
Share this with friends!
To engage in commentary, kindly proceed by logging in or registering
Subscribe to Our Newsletter
Stay ahead of the curve! Join our newsletter to see what everyone’s talking about.
0 Comments