Generate Model, Controller outside of app folder in Laravel

前端 未结 2 1965
有刺的猬
有刺的猬 2021-01-23 08:19

How to create controller and model files outside of app folder. For example, when we do

php artisan make:model ModelName

it creates Model file

相关标签:
2条回答
  • 2021-01-23 09:07

    I don't see the reason, but I managed to make it on my local computer by php artisan make:model ../../mOdel . Probably in production environment you won't be allowed to do this.

    0 讨论(0)
  • 2021-01-23 09:09

    Yes you can achieve this via below steps:

    1) Change psr-4 value for 'App' into composer.json file

    2) Run composer dump-autoload command for load composer

    3) Run command for manually created model php artisan make:model yourfoldername/model

    NOTE: Make sure, whenever you create model using command you need to change namespace.

    0 讨论(0)
提交回复
热议问题