I created controller which name is Home
but I want rename it with HomeController
. Is it possible in laravel?
Example:
class Home extends Controller { }
I Want to rename it like
class HomeController extends Controller { }
I Want to do it with CLI.
您必须手动执行此操作,没有任何命令可用于更新的控制器名称。
You can't use artisan
, but you can do it manually. But it's not just a simple rename.
You have to:
vendor/composer/autoload_static.php
vendor/composer/autoload_classmap.php
You can assess the file using nano
command or vi
, it depends on your machine. it basically an editor the enable you to change the content of the file.
Make a new Controller with the new Name.
php artisan make:controller NewController
or
php artisan make:controller NewController --resource
//if it is a resource controller
Now copy all contents from Old Controller to NewController.
Then edit all routes (in web.php) to that Controller.
忘记 CLI为什么不尝试使用“ AS ”重命名控制器
use app\MyController as MyControl;
I think doing composer dump-autoload
this regenerates the files:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.