[HowTo] Change User Model Namespace in Laravel

Laravael User Model
By default Laravel’s “User” model is place on “App” namespace.

To move it to App\Models namespace we have to do the following:

  1. Move User.php to App\Models folder
  2. Update this path in config/app.php
    Search for “providers” key and update the path in “model”
    before : App\User::class, after: App\Models\User::class
  3. Generate new class path by using composer dump-autoload
  4. Test the path and make sure it works.

I would recommend this doing in very early stage of the project. Otherwise, we might be breaking lots of things and without proper test cases in places, we will be creating extra mess for ourselves.

2 Replies to “[HowTo] Change User Model Namespace in Laravel”

    1. I can’t exactly remember which version I was working with at that moment so can’t remember which file was it. It might have been moved from config/app.php to config/auth.php overtime. Which version of Laravel did you try with?

Comments are closed.