There is another important knowledge point in the process of learning to load configuration files, which is Yaconf, which will be introduced below. Learning how to use yaconf will be of great help in learning the source code in the framework later.
3. Understand Yaconf
I guess some students know that Yaconf is our awesome Klass bird Written by my brother.
After Kaka learned about Yaconf, he summarized several reasons for launching this open source.
- There are too many configuration files, resulting in too long loading time
- The configuration files are poorly readable and need to be parsed
- Configuration files and code belong to the same project and there will be security risks when deployed together. At the same time, if the configuration file is modified, an online process is required.
- Increase collaboration between operation and maintenance and development Difficulty, if operation and maintenance needs to modify MySQL or other configurations, development needs to be notified to make simultaneous modifications
Then let’s talk about the advantages of using Yaconf
- Not together with the code, use a dedicated configuration directory
- When PHP starts, all configurations are loaded and resident in memory, accompanied by PHP Life cycle survival, avoiding the time-consuming process of parsing the configuration file for each request
- Separate the configuration file from the code, you can use the configuration background management to uniformly manage the configuration information
- If the configuration file changes, it will be reloaded (the suggestion given here is to use mv instead of cp)
- Supports rich types, such as: string , array, section, and you can also use PHP environment variables and constants directly in the PHP configuration file
- The last point is that it is very simple to use
After understanding what Yaconf can do, start the next step. Don't just install, configure, and call it. Then after the operation is over, you don't know what it is for. It doesn't make any sense. .
The following will introduce how to install and use it on win and linux
Persistence in learning, persistence in blogging, and persistence in sharing are the beliefs that Kaka has always upheld since his career. 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 It's time to learn about Yaconf. For more information, please follow other related articles on the PHP Chinese website!