This article will briefly introduce the installation and use of yaml, so that you can understand it.
After the installation is completed, it is simple to use. Create a new kaka.yaml file in the config.
And write the following content. Remember that there needs to be a space after the colon in yaml. I won’t go into details about how to write yaml. After all, it is not often used. The instructions here are just for reading the framework code.Test yaml data reading
The read data is an array, that is to say, the data in yaml format is converted into array form.Where did you know this method?
Remember that in the loadFile method under the config class, different methods are loaded according to the file extension.
For the PHP type, set is used directly. For the yaml type, the data is processed into an array and then the set method is executed.
If it is other types, the corresponding class name will be returned in the factory mode mentioned above. instance, and execute the method in the corresponding class to convert the format into an array form. In the end, the set method is still used.
Other types of configuration files will eventually go to the set method.
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 ThinkPHP's first experience with yaml. For more information, please follow other related articles on the PHP Chinese website!