166 thoughts on “How to Make User Login and Registration Laravel 5.1

  1. robbiebakkie says:

    Hi Bill,

    I followed your instructions and they are really good! But I have a question for you. I followed your steps and also created and migrated my database with user login/registered data. But when I try to register a person, I get an error as you can see below:

    FatalErrorException in RegistersUsers.php line 32:
    Call to a member function fails() on null

    Do you know how I can solve this?

    Like

  2. jkkmut says:

    I get NotFoundHttpException in RouteCollection.php line 161: for all the three routes except the ‘welcome’ route after following this tutorial

    Like

  3. Nda says:

    Hi Bill
    I am using the same tuts with Laravel 5.2.24 but receiving this errors when i try to logged in or to access home page after registration

    FatalThrowableError in EloquentUserProvider.php line 130: Fatal error: Class ‘\User’ not found

    Please any helps ?

    Like

      • Thanks Bill for the insight. Does this mean that we do not need php-jwt package to support token based authentication system. I am iOS developer and want to write mobile api using Laravel. I could not find a way to write the signUp api although I did login using php-jwt and I have also created other apis but I am not getting signUp to work.

        Like

      • I’m not sure about that, I have not use jwt for authentication myself personally yet. Let me know how this goes for you, perhaps you can come back and do a guest tutorial or article or something…

        Like

      • John R. says:

        I actually am struggling with this same issue. Auth with a valid token isn’t really the challenge. The problem is that you can post directly to the /register route to create a new user, but if there’s an error, it doesn’t return the error to the client application. All attempts just redirect to / with no success/failure feedback. I’m trying not to have to duplicate the whole auth mechanism just to get this working, but I can’t seem to find a straightforward way to handle it. See here for more detail: http://stackoverflow.com/q/38078512/5425432

        Like

      • Sorry, if I understand you correctly, what you are trying to do is outside the scope of the tutorial. I try to follow the baked in way of doing it because it saves a lot of headaches.

        Like

      • John R. says:

        I’m definitely not trying to do anything far out here. But, like the person mention in the original comment, I need my mobile app to be able to create and modify users through REST calls (without directing people to a web page). I can tell there’s an easy way to accomplish this without reinventing everything, but I’ve struggled to actually find that solution. I think the simplest answer might be to just build an alternate view controller for the registration page and, instead of returning a blade template, just return response()->json($errors). I’ll play with it tonight and see if I can make that work.

        Like

  4. snehal says:

    hello..
    after install laravel when i write php artisan make:auth in cmd, it gives error like command make:auth not defined..
    please reply..

    Like

    • make sure you are running laravel 5.2. Then you can run php artisan list to see if the make:auth command is in there. It should be. As of laravel 5.2.31, the make:auth command is still there.

      Like

  5. I’m using Laravel 5.1 and I’ve followed this tutorial as best I could. When I submit my logon credentials, I get this error:

    “`BadMethodCallException in ServiceProvider.php line 234: Call to undefined method [setPresenceVerifier]“`

    I’ve found this post https://laracasts.com/discuss/channels/laravel/validation-setpresenceverifier-error-in-custom-validation-class wherein the auhor says they added the presence verifier to their custom validation class. But, since I’m not using a custom validation class, I am not sure where to add that.

    Has anybody else encountered this problem and resolved it?

    Like

    • In Laravel 5.2 and above, php artisan make:auth will get you all the forms and a working registration and login on a fresh install, as long as your DB is configured. I have not encountered the problem you are describing. The subsequent versions of Laravel, 5.2 and 5.3, are easier to work with and I would encourage you to work with the a newer version if you can. The framework just gets better and better.

      Like

      • Thanks for you help, Bill, and your great tutorial. My problem was actually related to some custom validation code that I had stupidly chosen not to develop in a branch.

        I had chosen laravel 5.1 because it was labeled LTS. I had hoped that it would provide some stability, and not have to stay on the bleeding edge : /

        Like

  6. The last version of that book is for 5.2. I will not be updating it because 5.3 represents a significant leap in accessibility for beginners in subjects such as Elixir and Vue.js and I’m writing a lot of new material for that. The architecture is just beautiful. I’m working on a new book for 5.3, which will be released around the same time as the official launch of 5.3, which is very soon. Laravel evolves very quickly, but rather than fight or fear that, I’ve embraced it, and the framework just keeps getting more amazing.

    Like

    • I’m not really afraid of that — I decided to do a project in Laravel to learn something new– I just wish 5.1 wasn’t called Long Term Support if it’s not going to be recommended during its lifetime. It’s just only over a year old.

      If in a year’s time the solutions to the problems I encounter with 5.2 are to upgrade to 5.3 or later, I’m not going to be a happy camper. How much rewriting will I have to do when I upgrade?

      Like

      • I’m not an official member of the Laravel team, so my recommendations do not have anything to do with them or their long term support. If you are working on a giant project, then it’s not practical to constantly update. For smaller projects, you can update the project quickly. The thing is, you get more capabilities out of each subsequent version and I think that’t totally worth it. I wasn’t using Elixir until recently, and Laravel 5.3 just made it easy to set that up with Vue.js, it comes configured out of the box. So I was able to adapt my Vue.js datagrid to a very robust module/component architecture that is easy to work with. Prior to 5.3, I chose not to use Elixir because I wasn’t doing anything sophisticated enough to justify it. Now I wouldn’t dream of not using it. Laravel is also evolving to handle stateless authentication. I have not used that myself, but it is very robust. It’s an enterprise framework, which many companies are using, so it’s worth staying current on, in my opinion. I’m going to do a longer blog post about it after I have finished my book.

        Like

  7. Jungmyung says:

    hello, first of all Thank you for your tips . But I wonder path that have ThrottlesLogins,AuthenticatesUsers traits. Can I paste on AuthController.php file?

    Like

    • Hi, I’m not sure I understand your question correctly. Also, if you are looking for basic auth out of the box, install Laravel 5.3, and run php artisan make:auth It will create the views for you.

      Like

  8. Arvin Shelby de Leon says:

    Hello, I’ve followed every bits and pieces of this tutorial but when I login I don’t get an error but it’s keep me redirecting to the login page. Any clue on that?

    Like

    • If you are using Laravel 5.3, please use the php artisan make:auth command with a fresh install of Laravel. It will create all the views and home controller for you. The tutorial for 5.1 will not be appropriate for 5.3. You can check your version by running php artisan -V from the command line. Hope that helps.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s