Home> PHP Framework> ThinkPHP> body text

In-depth analysis of ThinkPHP configuration source code

咔咔
Release: 2020-10-09 16:02:37
Original
1614 people have browsed it

This article mainly analyzes the source code of Config in depth, mainly analyzes the code in the config file, and annotates it step by step, so that you can better see the execution process of the code.

7. In-depth analysis of Config source code

In-depth analysis of ThinkPHP configuration source code
Insert picture description here

After parsing the previous code execution process, the last step will come to the config file, and then the load method will be introduced.

Then you need to go to the filethinkphp/library/think/Config.php. In the app file, load in the config class is finally called.

Let’s take a look at what we have experienced

In the load method, the final direction of the process will be in theloadFilemethod. As for why the elseif code does not Go, or this code is redundant.

Because when Yaconf is installed, the corresponding configuration file will be loaded directly after PHP is started.

If you don’t know about yaconf, please read the previous article

In-depth analysis of ThinkPHP configuration source codeAfter coming to the loadFile file

We all know that in the ThinkPHP framework, all files in the config directory are of PHP type

So after judging the type, we directly enter the set for data processing

include directly introduces the configuration files in the config directory, and all configuration files directly return an array

In-depth analysis of ThinkPHP configuration source codeIn the set method, this code is the core

Keep merging arrays in a loop, and finally return all configuration information to the config attribute

Up to this point, all configurations in the config directory have been loaded.

In-depth analysis of ThinkPHP configuration source codeThe above is the loading process of config. In fact, after you finish reading, it doesn’t feel that difficult. It just depends on coding skills and ideas.

When we read the source code, we do not see how the code is written, but learn its coding ideas and finally implement them in our own projects.

Persistence in learning, persistence in blogging, and persistence in sharing are the beliefs that Kaka has always adhered to since its beginning. I hope that Kaka’s articles on the huge Internet can bring you a little bit of help. I’m Kaka, see you next time.

The above is the detailed content of In-depth analysis of ThinkPHP configuration source code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!