Creating login and registration functionality in Laravel 9 can be done quickly using laravel/ui package, a simple and minimal authentication package provided by Laravel. Here are the steps to set up login and registration:
Step 1: Set Up Laravel Project
Ensure you have a Laravel 9 project set up. If not, create one using the following commands:
composer create-project laravel/laravel project-laravel9
cd project-laravel9
Step 2: Set Up Database
- Open the
.env
file in the root directory of your Laravel project. - Update the database configuration to match your database setup:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password
- Run the migrations to create the necessary tables:
php artisan migrate
Step 3: Install Laravel UI
After Installing Laravel 9 we need to install laravel/ui package in order to generate authentication in laravel 9.
- To install run the composer command:
composer require laravel/ui
- After composer installation run artisan command to generate scaffolding:
// Generate basic scaffolding...
php artisan ui bootstrap
// Generate login / registration scaffolding...
php artisan ui bootstrap --auth
- After generating UI need to install npm dependencies.
npm install
npm run dev
- Run the migrations to set up the authentication tables:
php artisan migrate
Step 4: Test Authentication
- Start the development server:
php artisan serve
- Visit
http://localhost:8000/register
to register a new user. - Visit
http://localhost:8000/login
to log in with the registered user.
The output will look like:


Happy coding!