Laravel Authentication

Dikshant Rajput
2 min readMay 20, 2021

In today’s world, user security and privacy is the most important thing. Building a authentication system is not everyone’s cup of tea.

But with Laravel, it’s not that hard . There are many types of authentication that you can apply while building a website with Laravel. You can either use Laravel default authentication or can use any third party library like sanctum, passport etc.

Today I am going to tell something about Laravel’s default authentication

There are different types of authentication that are introduced in different versions of laravel but Laravel Bootstrap UI authentication is the best and most simplest one that you can use in your next project.

Best part is that there are no overhead while using this authentication. So let’s start…

Run this composer command to install Bootstrap Auth in your fresh Laravel project.

composer require laravel/uiphp artisan ui bootstrap --auth

As you see we have given bootstrap — auth flag to the php artisan ui command which tells the artisan tool to install auth with bootstrap as default scaffolding. So If you are familiar with any other library like vue or react you can easily install using them also. But bootstrap is the most simple and loved library so I will be taking it as a starting point.

After installing the dependency, you have to run

npm install && npm run devORyarn install && yarn run dev

If you don’t want to use npm run dev you can even use npm run watch

After running this, all the additional styling and javascript files will be installed in your node_modules folder.

Your Bootstrap scaffolding is now ready and test it by running the server first with

php artisan serve

Open the page in browser and go to {localhostURL}/register e.g. localhost:8000/register

Default register page

Laravel by default have User Model created for you and the authentication now works hand on hand with User Model. If you want to add or remove any field you are free to do that.

Now test your application by registering and logging with different users.

Congratulations!!! You have successfully installed authentication in your laravel project. In next blog post I will be telling you how to twerk the default fields and how to made this authentication more project friendly.

If you like this, please hit that clap icon and If you want more Laravel stuff, don’t forget to follow me.

--

--