Laravel Create Model Outside App Namespace
I want to use the command php artisan make:model User
for creating an user inside the domain folder. Nevertheless it will end up in the App folder.
I've already tried this:
php artisan make:model Domain\User
php artisan make:model Domain\\User
php artisan make:model \\Domain\\User
php artisan make:model Domain/User
app folder:
app
|
+-- App
|
|
+-- Domain
|
|
+-- Http
composer file:
"autoload": {
"psr-4": {
"App\\": "app/App/",
"Domain\\": "app/Domain/",
"Http\\": "app/Http/",
"Support\\": "app/Support/"
},
UPDATE
php artisan make:model ../Domain/User
solved the problem for model. I have stil the problem with a controller php artisan make:controller ../Http/UserController
Answer
Not sure why you need to create a model outside the default location.
Artisan make commands will attempt to store the files in the standard location according to the command you running.
As an example, php artisan make:model User
will create the model inside app
directory (default directory for models). So assuming the desired destination for your model is one directory above and has the name Domain you can run the following command:
php artisan make:model ../Domain/User
Note that ../Domain/
is relative to the default location for that command.
For a controller, knowing the default directory is app/http/Controller
and you want to generate a controller in Domain/http/Controller
you can do it with the following command:
php artisan make:controller ../../../Domain/Http/UserController
Please note that this isn't usual and is not following the standards.
Hape that helps you with what you are trying to achieve
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?