[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.

Leave a Reply

Your email address will not be published. Required fields are marked *