27

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

php artisan make:controller PageSettings

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

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?

Fusion
  • 5,046
  • 5
  • 42
  • 51

4 Answers4

50

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.php you should remove them from routes.php file or alter the file to reflect your new controller.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
7

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

Tomislav
  • 3,181
  • 17
  • 20
7

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

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 update then composer dump-autoload. After that, everything worked just fine.

Ashton Wiersdorf
  • 1,865
  • 12
  • 33
3

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.