1

In Laravel 5.2 fresh installation, i'm trying to get the Authentication features (Register/ Login/ Logout/ etc), by following the documentations. Here are the steps i made.

# php artisan make:auth

Created View: /var/www/html/example.com/resources/views/auth/login.blade.php Created View: /var/www/html/example.com/resources/views/auth/register.blade.php Created View: /var/www/html/example.com/resources/views/auth/passwords/email.blade.php Created View: /var/www/html/example.com/resources/views/auth/passwords/reset.blade.php Created View: /var/www/html/example.com/resources/views/auth/emails/password.blade.php Created View: /var/www/html/example.com/resources/views/layouts/app.blade.php Created View: /var/www/html/example.com/resources/views/home.blade.php Created View: /var/www/html/example.com/resources/views/welcome.blade.php Installed HomeController. Updated Routes File. Authentication scaffolding generated successfully! 

# cat app/Http/routes.php

<?php use Illuminate\Http\Request; Route::group(['middleware' => ['web']], function () { Route::get('/', function () { return view('welcome'); }); }); Route::group(['middleware' => 'web'], function () { Route::auth(); Route::get('/home', 'HomeController@index'); }); 

# php artisan migrate:install

Migration table created successfully. 

# php artisan migrate

Migrated: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_100000_create_password_resets_table 

(Here i'm not sure why it is dated as "2014", anyway.)

After this, i can already see below tables get created in my MySQL database:

  • migrations
  • password_resets
  • users

[ So i assume the Database connection is also correct! ]
[ And also the Home page with "Login" "Register" "Login Form" etc are appeared, properly. ]

Problem

Now, when i go to /register there's a nice Registration Form already appeared. But when i fill-in and SUBMIT, nothing happens. (It keeps routed back to the /register page as nothing happened.)

Then when i checked from Apache Access Logs, the request is shown as "GET". I think this is supposed to be a "POST". Am i right?

(And nothing in the Error Logs as well)

What is happening please?

4
  • What is your controller file for register? Commented Apr 4, 2016 at 9:40
  • This is my first Laravel installation. So I'm not sure. But according to tutorials, after these steps, the login/logout/registrations should be already working. Am i right to say that please? (Because this is purposely the feature of LV5.2. Right?) Commented Apr 4, 2016 at 9:41
  • AuthController needed for laravel authentication.You can try step by step from laravel.com/docs/5.2/quickstart-intermediate.It is very easy for a beginner. Commented Apr 4, 2016 at 9:47
  • move your all routes to the group and thats it. Commented Apr 4, 2016 at 18:17

2 Answers 2

2

I got it solved by myself.

(1) It needs following functions in the app/Http/Controllers/AuthController.php:

public function getRegister() { return $this->showRegistrationForm(); } public function postRegister(Request $request) { return $this->register($request); } 

(2) In the Router routes.php file, the function Route::auth(); call must be defined only after the other functions (under the same middleware group). Like:

Route::group(['middleware' => 'web'], function () { Route::get('/home', 'HomeController@index'); Route::auth(); }); 

( The Route::auth(); can not come first. )

Thanks all for all your kind helps :)

Sign up to request clarification or add additional context in comments.

Comments

1

Try to remove web middleware, cause a lot of guys have issues with it past two weeks (since minor Laravel update). Now web middleware applies automatically to all routes and when you add it manually, it causes different kind of errors.

2 Comments

Which web middleware you mean please? Because i used 2 of them in my file above. Or you mean to totally remove all web middlewares at all? (By the way, i found there's no function register in my AuthController.php. Is it normal? Is it inherited from somewhere?)
Remove all web from routes. AuthController uses two traits, so I guess function is in one of them.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.