Q . Laravel created model and moved file to another directory.

Dev Singh. asked, Aug 13 ' 2016

I have made a Models folder and I have moved all my models there. All is working fine. Now I want to change the path where this command

php artisan make:model SomeModel

put the generated model. How can I change it?

  • folder
  • Laravel

1 Answers

You can't and, if you're hewing to Laravel's version of the universe, you shouldn't. Laravel 5 provides, and assumes, a PSR-4 naming convention for all its class files. This means models (and all classes) should be placed based on their full class name.

When you say

php artisan make:model SomeModel

You're actually creating a model with the full name of App\SomeModel, so artisan creates the following file.


If you said

php artisan make:model 'Test\SomeModel'

you'd be creating a model with the full name App\Test\SomeModel, and Laravel would create the following file


So, its your model's full class name (namespace included) that determines where the class definition file is.

Leave a Ansewer