How to Use Authentication in Laravel 5.7?

Before you jump into this blog to implement Authentication module in your Laravel application, I’m sure you have your Laravel application up and running. If you don’t then follow the link below to install Laravel on your machine for the first time and also develop a CRUD application using Laravel:

  1. How To Install Laravel Framework in Ubuntu?Laravel5.7, PHP7.1.26
  2. Laravel5.7 CRUD Operations Examples from Scratch.

Following the above two tutorials, you can easily set up your first ever Laravel application which does a simple CRUD operation. Now let’s apply authentication to your app.

Implementing authentication is actually easy a line command does all your login/register stuff. Let’s do it.

In your terminal type following command:

php artisan make:auth

This single command does all your work, it bundles the views, core PHP codes and CSS styles, JavaScript for you. Following new files and directories were created after creating authentication:

  1. A HomeController is created which implements the auth middleware in Http/Controller directory
  2. Views are created in your auth directory in resources/views/auth
  3. You can find your auth API implemented in api.php file inside routes directory where the route is implemented as following:
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();

Now you will clearly see a login and register menu in your home page after you deploy your application.

That is all which needs to be covered for authentication. To catch up more about Laravel project like Installation, CRUD application, missing php extensions, errors in key generation follow the Laravel category from the link below:

Blog Tutorial Category: Laravel

%d bloggers like this: