欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Laravel - Method [xxx] does not exist on [xxx]

程序员文章站 2022-12-22 14:51:44
The controller is existing, and the method 'test' exist on 'App\Http\Controllers\Admin\IndexController'. But Laravel show me that there is no method o ......

the controller is existing, and the method 'test' exist on 'app\http\controllers\admin\indexcontroller'. but laravel show me that there is no method on the controller, i don't know why. i have askd for help on the internet, but no one can help me. the error like pic1.

Laravel - Method [xxx] does not exist on [xxx]

 

 now i show you my project folder and the files.

Laravel - Method [xxx] does not exist on [xxx]

 

 the namespace of the indexcontroller.php is right. and the method test is existed. but laravel told me that method does not exist... i don't know what happend!

maybe you have the same trouble, now, i will give you a way to solve the problem. then, let's go.

look at this file.

Laravel - Method [xxx] does not exist on [xxx]

 

 there is a backup file in my project. i had edited the controller file after created the backup file. so the content of the two files is different. initially, there is no problem. but when i execute the command "composer update"... oh, my god!

now, look at the directory vendor/composer, and open the file autoload_clappmap.php and autoload_static.php. search indexcontroller in the two files.

in autoload_classmap.php:

Laravel - Method [xxx] does not exist on [xxx]

 

 in autoload_static.php:

Laravel - Method [xxx] does not exist on [xxx]

 

 look at the red box. the real file is not indexcontroller.php, but is the backup file. i have said, the two file is different. the method test does not on indexcontroller.bk.php. so laravel show me the error.

we have known why the problem happend. now, we should solve it.

1) update the 'indexcontroller.bk.php' to 'indexcontroller.php' that in the autoload_classmap.php and autoload_static.php.

2) or you can delete the backup file or move it to other directory, then do 1).

3) or you can delete the backup file or move it to other directory. then execute the command composer update. but it is slow...

 

report:

developing good programming habits can avoid many mistakes.