Home  >  Article  >  Backend Development  >  Solve the problem that the controller cannot be loaded in the ThinkPHP framework - one of the reasons

Solve the problem that the controller cannot be loaded in the ThinkPHP framework - one of the reasons

PHP中文网
PHP中文网Original
2017-03-31 17:15:114676browse

Solve the problem that the controller cannot be loaded in the ThinkPHP framework - one of the reasons

I believe that many PHP developers have encountered the problem in the picture when using the ThinkPHP framework for rapid development when accessing the controller method through the URL.

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

You do not store the files of your controller in your Controller folder, because it is very likely that you are in When I started learning or testing, I wrote the controller class in the Index controller file, but in ThinkPHP, it is irregular to write two classes in the IndexController.

class.php file, because if the two classes are written in the same file, then when accessing other classes other than the file name through 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 do not create this file, you cannot expect the system to help you find it from IndexController.class. The .php file is found 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 ThinkPHPConfconvention.php and saw this

Solve the problem that the controller cannot be loaded in the ThinkPHP framework - one of the reasons
The second line showed that the parameter binding function was turned on, so it denied my original idea. After consulting other people, I realized that there was no new file, so I wrote this blog. I hope to encourage all PHP developers not to make such stupid mistakes again.

The above is one of the reasons for solving the problem of being unable to load the controller in the ThinkPHP framework. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn