Home  >  Article  >  PHP Framework  >  Solve the problem that the controller in thinkphp cannot be loaded

Solve the problem that the controller in thinkphp cannot be loaded

尚
forward
2020-04-23 09:18:225124browse

Solve the problem that the controller in thinkphp cannot be loaded

When we use the ThinkPHP framework, we may encounter the problem of being unable to load the controller:

Solve the problem that the controller in thinkphp cannot be loaded

I believe that many PHP developers are When using the ThinkPHP framework for rapid development, I encountered the problem shown in the figure when accessing controller methods through URLs.

Why the controller cannot be loaded? There are many reasons, but from what I know, the most likely ones are:

Your controller is not stored in your Controller folder file, because it is very likely that you wrote the controller class in the file of the Index controller when you started learning or testing, but in ThinkPHP, it is not standardized to write two classes in the IndexController.class.php file. Because if two classes are written in the same file, then when accessing other classes other than the file name through the URL, it will be like this, http://localhost:81/thinkphp_3.2.3_core/index.php/Home/Blog /read/5, the system cannot find this controller.

In other words, the system can only find this controller through the file name BlogController.class.php. If you have not created this file, you cannot expect the system to help you find it from the file IndexController.class.php. Because if the file BlogController.class.php cannot be found in the Controller folder, the system will think that you have not written this controller, so that error will occur.

I originally thought it was because the parameter binding function was not turned on, but I found ThinkPHP\Conf\convention.php and saw this

Solve the problem that the controller in thinkphp cannot be loadedThe second line shows that the parameter binding function is turned on , so I rejected my original idea. Later, after consulting other people, I realized that the reason was that there was no new file.

The above is the detailed content of Solve the problem that the controller in thinkphp cannot be loaded. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete