Simple and Easy Laravel 5.2 Login and Register using the auth scaffold

Simple and Easy Laravel 5.2 Login and Register using the auth scaffold

Simple and Easy Laravel 5.2 Login and Register using the auth scaffold

Here i am going to use Laravel auth scaffolding to login and register, its very easy to integrate login and register system in Laravel.

Step 1: Install Laravel 5.2

If Laravel is not installed in your system then first install with following command and get fresh Laravel project.

composer create-project --prefer-dist laravel/laravel blog "5.2.*"

When you run above command then it create application with name blog in your system.From Laravel 5, you have to install laravelcollective/html for Form class.To know the installation process of laravelcollective/html, kindly go through this url HTML/FORM not found in Laravel 5?.

Step 2: Create users table and model

Follow the simple step to create users table in your database.First create migration for users table using Laravel 5 php artisan command,so first run this command -

php artisan make:migration create_users_table

After this command, you will see a migration file in following path database/migrations and you have to simply put following code in migration file to create users table.


  1. use Illuminate\Database\Schema\Blueprint;
  2. use Illuminate\Database\Migrations\Migration;
  3. class CreateUsersTable extends Migration
  4. {
  5. /**
  6. * Run the migrations.
  7. *
  8. * @return void
  9. */
  10. public function up()
  11. {
  12. Schema::create('users', function (Blueprint $table) {
  13. $table->increments('id');
  14. $table->string('name');
  15. $table->string('email')->unique();
  16. $table->string('password');
  17. $table->rememberToken();
  18. $table->timestamps();
  19. });
  20. }
  21. /**
  22. * Reverse the migrations.
  23. *
  24. * @return void
  25. */
  26. public function down()
  27. {
  28. Schema::drop('users');
  29. }
  30. }

Save this migration file and run following command

php artisan migrate

If you receive a "class not found" error when running migrations, try running the composer dump-autoload command and re-issuing the migrate command.

Now you have successfully created `users` table.You won't have to create user model, it is created by default in following path app/User.php when you install Laravel.


  1. namespace App;
  2. use Illuminate\Foundation\Auth\User as Authenticatable;
  3. class User extends Authenticatable
  4. {
  5. /**
  6. * The attributes that are mass assignable.
  7. *
  8. * @var array
  9. */
  10. protected $fillable = [
  11. 'name', 'email', 'password',
  12. ];
  13. /**
  14. * The attributes that should be hidden for arrays.
  15. *
  16. * @var array
  17. */
  18. protected $hidden = [
  19. 'password', 'remember_token',
  20. ];
  21. }
Step 3: The auth scaffold in Laravel 5.2

Laravel provide a short cut to create auth section

php artisan make:auth

After successfully run command, Laravel create complete auth section which you will see in your command promt -

php artisan make:auth


List of files and folder which is generated by above command :

It generate a master layout which is core of scaffold resources/views/layouts/app.blade.php

List of views that extend it :

  • welcome.blade.php - the welcome page
  • home.blade.php - the landing page for logged-in users
  • auth/login.blade.php - the login page
  • auth/register.blade.php - the register or signup page
  • auth/passwords/email.blade.php - the password reset confirmation page
  • auth/passwords/reset.blade.php - the password reset prompt page
  • auth/emails/password.blade.php - the password reset email

Changes in routes.php :

  1. Route::auth();
  2. Route::get('/home', 'HomeController@index');

The Route::auth() is a set of common authentication, registration and password reset routes.

  1. // Authentication Routes...
  2. $this->get('login', 'Auth\AuthController@showLoginForm');
  3. $this->post('login', 'Auth\AuthController@login');
  4. $this->get('logout', 'Auth\AuthController@logout');
  5. // Registration Routes...
  6. $this->get('register', 'Auth\AuthController@showRegistrationForm');
  7. $this->post('register', 'Auth\AuthController@register');
  8. // Password Reset Routes...
  9. $this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
  10. $this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
  11. $this->post('password/reset', 'Auth\PasswordController@reset');

Benefits of using scaffolding in Laravel is you don't have to create routes, controllers and views for login and register.It helps you to save 30 to 60 minutes of typing on every app that needs it.

Now let's have a look at what we get in browser.

Phone: (+91) 8800417876
Noida, 201301
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort otele gelen escort sapanca escort söğütlü escort taraklı escort
sakarya escort - akyazı escort - arifiye escort - erenler escort - eve gelen escort - ferizli escort - geyve escort - hendek escort - karapürçek escort - karasu escort - kaynarca escort - kocaali escort - otele gelen escort - pamukova escort - sapanca escort - söğütlü escort - taraklı escort
sapanca escort hendek escort karasu escort escort sakarya sakarya escort bayan adapazarı escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort