Laravel Breeze

What is Laravel Breeze, what does it offer us to improve the possibilities of Laravel and the entire login process, user registration, verification, etc. What pieces of code are included and how to install and configure the system.

Laravel Breeze consists of a scaffolding of a web applicationsimple and understandable, that can be installed on top of clean Laravel projects and that offers authentication functionalities already implemented From home. This includes login and registration, but also other basic application needs such as recovering forgotten passwords, email verification, etc.

If you are new to Laravel or you want the stack of technologies that the home framework mounts for you to be as minimal as possible, Laravel Breeze is a good alternative, since to work it simply uses the Blade template system.

It also integrates with Tailwind from home, though it’s easily interchangeable with any other CSS framework, Sass, or the ever-existing alternative of writing your CSS completely by hand.

Installing Laravel Breeze

In order to get started with Breeze we need to previously install Laravel itself. You can do this using any of the methods that we have described for installing in the .

Once Laravel is installed and the project is clean, we can install Laravel Breeze with the following command.

composer require laravel/breeze –dev

Remember that if you work with Sail, you will have to run the commands from the container, so you will need to prepend “sail” before all these commands: sail composer require laravel/breeze –dev

Next we are going to publish all the elements that Laravel Breeze has provided us, using the command:

See also  Share the same header and footer for several pages of a website

php artisan breeze:install

We can then install frontend dependencies and run migrations to make sure that all the necessary components for Laravel Breeze to work are ready in your project.

php artisan migrate

On Mix-based installations of Laravel Breeze (currently works with Vite for frontend asset compilation) it was also necessary to run these commands:

npm install npm run dev

Install the features for API authentication

If the idea is develop an API with Laravel we can use Breeze Also as a starter kit, but in this case we will need to install the scaffolding of the API authentication system, through the following steps.

First we must have installed Breeze via composer with the command that was pointed out at the beginning. Then we perform the installation of breeze like this:

php artisan breeze:install api

You can run the migrations if you didn’t already have them:

php artisan migrate

This will have created two configuration variables in the .env that indicate where the servers of the frontend application and the backend application will be:

APP_URL=http://localhost:8000 FRONTEND_URL=http://localhost:3000

APP_URL will be used for when you serve the app via php artisan serve. If we want port 8000 to work we have to configure docker-compose.yml ports:

  • ‘${APP_PORT:-80}:80’
  • ‘8000:80’

What’s included Breeze

For those who have been in Laravel for a long time, we could summarize this point by saying that Breeze includes more or less what we had with , that is, the modules, routes and controllers to create a complete login system.

When entering our website with Breeze, we can see this page, where the login and registration links are located at the top right.

See also  Laravel Handbook

The login and registration forms are offered with a very attractive design that is easily adaptable to any application. For the definition of this design, .

Already in pieces of code, we can find in the “models” folder the User model (User.php). And in Http/Controllers/Auth we find a whole series of controllers that allow us to implement the basic needs of the login and registration system.

Additionally, the application paths system-wide user control is defined in routes/auth.php, which is a file that is included directly from the web routes in routes/web.php.

You will find routes for the login and registration pages, but also for the email sending pages to reset the password, create a new password, verify the user’s email and for the user’s logout.

Laravel Mix in Laravel Breeze

Another of the things that Laravel Breeze does is the generation of a frontend file compile code custom, which is located in the webpack.mix.js file in the main path of the project.

Inside the webpack.mix.js file you will find the Laravel Mix configuration, which is a layer above Webpack. This file is responsible for configuring how the compilation of the frontend code assets, such as Javascript and CSS, will be done.

If you want to use a custom frontend technology stack you’ll need to start by editing this file, for example by removing the Tailwind payload, if you don’t plan to use this CSS framework.

To better understand the code in the webpack.mix.js file and the file compilation Mix performs in general, you can read the .

See also  How to install Composer

conclusion

Laravel Breeze doesn’t have much else, it’s a elementary scaffolding of the entire login and user registration process. It will take a lot of work out of you on new applications that require users (pretty much all of them) and will help you get started with a slightly larger set of files.

If you want more possibilities, Laravel also includes a complete scaffolding package called Jetstream, which handles things like two-factor authentication.

Loading Facebook Comments ...
Loading Disqus Comments ...