Laravel 5.1 remove controller

59,175

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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.

Share:
59,175

Related videos on Youtube

Fusion
Author by

Fusion

I am python dev with passion for data-engineering. Currently I am flirting with data-analysis and who knows... maybe machine learning learning and AI in the future?

Updated on July 09, 2022

Comments

  • Fusion
    Fusion almost 2 years

    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?

  • Keith Becker
    Keith Becker about 5 years
    I think you also need to regenerate the composer autoload file.
  • VishalParkash
    VishalParkash about 4 years
    so that means there is no command to remove controller via artisan?