How to realize on-line automatic loading exception and repair method by thinkPHP
This article mainly shows you the "thinkPHP how to achieve online automatic loading exceptions and repair methods", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "thinkPHP how to achieve online automatic loading anomalies and repair methods" this article.
The details are as follows:
The project encountered a strange problem, the local code is normal, but not on the server.
After testing, there should be something wrong with the automatic loading and tried various methods.
1. Manual loading, found good trouble, endless.
two。 Write their own automatic loading, can not write out, embarrassed.
3. Modify the configuration to support automatic loading, but it still doesn't work.
Debugging was carried out later.
Discover local support
Import ('@ .ORG.OSS\ OssClient'); import ('@ .ORG.OSS\ Core\ OssUtil')
On the server, this slash is not supported, but it is supported. The way
Later, the core code of thinkphp was adjusted.
/ / try to search $paths = explode (',', C ('APP_AUTOLOAD_PATH')); foreach ($paths as $path) {$class = str_replace ("\\", ".", $class); / / dump ($class); if (import ($path.'.'.$class)) {/ / dump ($path.'.'.$class); / / return return if the class is loaded successfully;}
After this small action, OK, the server can use OSS.
The above is all the contents of the article "how to automatically load exceptions and fixes online by thinkPHP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!