Home > PHP Framework > ThinkPHP > body text

ThinkPHP's first experience with yaml

咔咔
Release: 2020-10-09 16:05:59
Original
1767 people have browsed it

This article will briefly introduce the installation and use of yaml, so that you can understand it.

8. First experience with yaml

##yaml is a data communication method similar to xml and json. But YAML is data-centric, not markup language-focused.

Yaml is mentioned here because it is mentioned in the framework source code. The subsequent process also requires yaml, so you still need to briefly understand it!

To install yaml, search for yaml directly in pcel and download the corresponding version. The download method is the same as the previous yaconf installation.

After successful installation, this extension will exist in PHP.

What needs to be noted here is that you need to add the yaml extension file to php.ini!

If you don’t know how to install it, go to the Yaconf installation on window section to see how to install it, and just install the process.

After the installation is completed, it is simple to use. Create a new kaka.yaml file in the config. ThinkPHPs first experience with yaml

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 readingThinkPHPs first experience with yaml

The read data is an array, that is to say, the data in yaml format is converted into array form.

ThinkPHPs first experience with yamlWhere 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.

ThinkPHPs first experience with yamlOther types of configuration files will eventually go to the set method.

ThinkPHPs first experience with yaml
Insert picture description here

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!

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
Popular Tutorials
More>
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!