Laravel authentication using Laravel Breeze

Laravel team have created multiple authentication package that provide easy access to create full authentication system. These packages includes Laravel Breeze, Laravel Jetstream and Laravel Fortify.

Laravel Breeze is simple and easy install package for Laravel's all authentication features. including login, registration, password reset, email verification, and password confirmation.

In this article we will create a fresh Laravel application and install Laravel Breeze package which includes all authentication features. So let's start by creating new Laravel application.

Note: You should have installed Composer and NPM in system. Composer is required to install Laravel and PHP packages in Laravel application. Though NPM is not necessarily required if you are building your own views but it required for compile your assets so that your application's default views:

Step 1: Create a new Laravel application

In the first step, we will create a new Laravel application using composer command. So open Terminal or Command Prompt and run the following command.

composer create-project laravel/laravel breeze

This will create a new Laravel application. Now change the Terminal directory of project.

cd breeze

Step 2: Database configuration

In your project's root directory, open .env environment file. In the file change MySQL credentials according to your MySQL.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=breeze
DB_USERNAME=root
DB_PASSWORD=root

Step 3: install Laravel Breeze

In the third step we will install Laravel Breeze package using composer command. Run the following command to install Laravel Breeze package.

composer require laravel/breeze

After the package install, you may run the breeze:install artisan command.

php artisan breeze:install

Step 4: Compile assets

Now we have installed Laravel Breeze, its time to compile assets using npm command. If you are not using Laravel's default views, then you don't need to run these commands. You can change views in applications authentication views at resources/views/auth/ directory.

To compile the assets run the below commands one by one.

npm install
npm run dev

Step 5: Run migration

We have configured the database, now we need to create tables in database. Laravel provide default migration for users table at database/migrations directory. You can change columns in the tables if you want. Now run the following migrate command to create tables in database.

php artisan migrate

That's it, run the Laravel server using php artisan serve command and from your browser, go to http://localhost:8000/login and http://localhost:8000/register. You can see all of application's authentication routes located at routes/auth.php file.

To get latest updates, like Facebook page and follow us on Twitter.