Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i rename laravel controller with command line interface(CLI)?

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.

like image 725
Roni Avatar asked Dec 19 '16 12:12

Roni


2 Answers

You can't use artisan, but you can do it manually. But it's not just a simple rename.

You have to:

  1. Rename the PHP file.
  2. Edit the PHP file to give the class the new controller name (the class name and the file name must match)
  3. Change any code that uses that old class name to use the new class name
  4. Edit the autoload files to load the new controller file:
vendor/composer/autoload_static.php
vendor/composer/autoload_classmap.php
like image 66
Majenko Avatar answered Nov 20 '22 09:11

Majenko


You have to do it manually, there is no any command available to updated controller name.

like image 27
Komal Avatar answered Nov 20 '22 07:11

Komal