ThinkPHP online automatic loading exception and Repair Method Instance analysis, thinkphp instance analysis
This article describes thinkPHP online automatic loading exceptions and solutions. We will share this with you for your reference. The details are as follows:
The project encountered a strange problem. The local code is normal, but the server is not normal.
After testing, the problem should be caused by automatic loading, and various methods have been tried,
1. Manual loading, which is troublesome and endless.
2. Write it automatically and load it by yourself.
3. modify the configuration so that it can be loaded automatically.
Later debugging,
Local Support discovered
Import ('@. ORG. OSS \ OssClient'); import ('@. ORG. OSS \ Core \ OssUtil ');
The server does not support this slash, but does.
Later, we adjusted thinkphp's core code.
// Search for $ paths = explode (',', C ('app _ AUTOLOAD_PATH '); foreach ($ paths as $ path) based on the automatic loading path settings) {$ class = str_replace ("\\",". ", $ class); // dump ($ class); if (import ($ path. '. '. $ class) {// dump ($ path. '. '. $ class); // return if the class is successfully loaded ;}}
After this small action, you can use OSS on the server.
Not easy!