THINKPHP supports setting YAML configuration files

Source: Internet
Author: User
This article mainly introduces how THINKPHP supports setting YAML configuration files. This article explains why to use yaml and how to configure THINKPHP. For more information, see Why yaml?

Yaml is simple and friendly to humans;

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

Where can I use it?

Basically, you can select the Yaml format in the ThinkPHP configuration file. are you willing to write the simple format configuration of Yaml? Are you willing to write a long, smelly, and hard-to-write PHP array?

Http://document.thinkphp1.cn/manual_3_2.html#config_format

The problem arises.

So I changed the configuration format to Yaml:

The code is as follows:


/// Index. php

// Define the configuration file format as yaml
Define ('conf _ EXT ','. yaml ');

Change all config. php under the Application directory to config. yaml.

At this time, an error is reported:

The code is as follows:


Class 'splitc' not found error location FILE: D: \ app \ think \ ThinkPHP \ Common \ functions. php LINE: 90


Find and find this section:

The code is as follows:


/**
* Parse the yaml file and return an array.
* @ Param string $ file configuration file name
* @ Return array
*/
If (! Function_exists ('yaml _ parse_file ')){
Function yaml_parse_file ($ file ){
Vendor ('spyc. spyc ');
Return Spyc: YAMLLoad ($ file );
}
}

It seems that the library Spyc is not found.

Looking for it, Spyc is here: https://github.com/mustangostang/spyc/

Then, what is this vendor?

Here: http://document.thinkphp1.cn/manual_3_2.html#autoload

Conclusion:

In the above Git, download Spyc. php and put it in the/ThinkPHP/Library/Vendor/spyc/Directory. everything works! 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.