thinkphp Support YAML configuration file Setup method _php tips

Source: Internet
Author: User

Why do you use YAML?

Because Yaml is simple and friendly to human beings;

yaml:http://www.yaml.org/

Where is it going to be used?

The most basic, in the thinkphp configuration file can choose the Yaml format, you are willing to write Yaml simple format configuration? Or are you willing to write long, smelly and difficult to write PHP array?

Http://document.thinkphp.cn/manual_3_2.html

Here's the problem.

So I changed the configuration format to Yaml:

Copy Code code as follows:

/index.php

The format of the definition configuration file is Yaml
Define (' Conf_ext ', '. Yaml ');

Then change the config.php in the application directory to Config.yaml.

This time, the error:

Copy Code code as follows:

Class ' SPYC ' not found error position file:d:\app\think\thinkphp\common\functions.php line:90

Then find, find this paragraph:
Copy Code code as follows:

/**
* Parse Yaml file returns an array
* @param string $file profile Name
* @return Array
*/
if (!function_exists (' Yaml_parse_file ')) {
function Yaml_parse_file ($file) {
Vendor (' Spyc. Spyc ');
Return Spyc::yamlload ($file);
}
}

Seemingly introduced SPYC This library was not found.

Looking for a moment, Spyc here: https://github.com/mustangostang/spyc/

Then, what is this vendor?

Look here: http://document.thinkphp.cn/manual_3_2.html

Conclusion:

In the above Git download spyc.php put into the/thinkphp/library/vendor/spyc/directory, everything is normal! Done with the right way!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.