Laravel 5.1 移除控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34692667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:13:31  来源:igfitidea点击:

Laravel 5.1 remove controller

laravelcontrollerlaravel-5laravel-5.1artisan

提问by Fusion

I have simple question on Laravel 5.1. I have created a controller using php artisan command:

我对 Laravel 5.1 有一个简单的问题。我使用 php artisan 命令创建了一个控制器:

php artisan make:controller PageSettings

However it was mistake, because I really wanted to create this controller in Admin folder like this:

但是这是错误的,因为我真的很想在 Admin 文件夹中创建这个控制器,如下所示:

php artisan make:controller Admin/PageSettings

Now I want to get rid of my old PageSettings controller. Is it ok just to delete my old PageSettings.php manualy? Or there is something more what needs to be done?

现在我想摆脱旧的 PageSettings 控制器。可以手动删除旧的 PageSettings.php 吗?或者还有什么需要做的?

回答by Marcin Nabia?ek

If you only created it and found that you did it wrong, you can manually remove the file and that's it. However when you already added routes to this controller in routes.phpyou should remove them from routes.phpfile or alter the file to reflect your new controller.

如果您只是创建它并发现您做错了,您可以手动删除该文件,仅此而已。但是,当您已经向该控制器添加了路由时,routes.php您应该将它们从routes.php文件中删除或更改文件以反映您的新控制器。

回答by Tomislav

It is OK to manually delete controller. Just check routes.php if you have some route to that controller and delete it also.

手动删除控制器是可以的。如果您有一些到该控制器的路由,只需检查 routes.php 并将其删除。

回答by Aitzaz Wattoo

Yeah, you can delete manually without tension. I will suggest you for avoiding more mistakes, you "phpStrom" software, from using this, if you delete manually any file from by click right of mouse->Refactor->safe delete then before deleting they will give all places which were using your file. by clicking "do refactor" you can delete it.

是的,您可以毫无压力地手动删除。我会建议你避免更多的错误,你的“phpStrom”软件,从使用这个,如果你通过单击鼠标右键手动删除任何文件->重构->安全删除然后在删除之前他们会给出所有使用你的地方文件。通过单击“进行重构”,您可以将其删除。

回答by Ashton Wiersdorf

I had an issue with just deleting the file. I tried running my PHPUnit test suite and got an error that looked like this:

我在删除文件时遇到了问题。我尝试运行我的 PHPUnit 测试套件并得到一个如下所示的错误:

Warning: include(): Failed opening '/user/home/me/some/file.php' for inclusion (include_path='.:') in /usr/home/me/some/vendor/composer/ClassLoader.php on line 444

I had to run composer updatethen composer dump-autoload. After that, everything worked just fine.

composer update那时我不得不跑composer dump-autoload。之后,一切正常。