Provides various official and user-released code examples. For code reference, you are welcome to learn ThinkPHP3.2.2 how to use the yaml configuration format to report errors
I haven't used ThinkPHP development for a long time. I have a small project to be developed and want to use ThinkPHP for development. So I downloaded ThinkPHP3.2.2 and found a composer. I am really happy to see this file in the json file, because it is much easier to manage third-party Code. For more information about composer, visit the composer official website, visit my blog Composer to help you easily manage the PHP package.
Another thing that made me better off was ThinkPHP3.2.2. yaml/json/xml/ini and custom format support were added to the configuration file. I prefer to use yaml format to configure some information, yes. I have added it to the main portal file according to the official documentation.
// Define the configuration format
Define ('conf _ EXT ','. yaml ');
Execute the main entry file and remind me to Call to undefined function yaml_parse_file (). According to the prompt information, the yaml_parse_file () function was not officially provided.
Parsing yaml has a mature spyc class that not only parses files in yaml format into PHP arrays, but also parses PHP arrays into yaml. Spyc
My solution is:
1. Create composer. json in your project directory
{
"require": {
"topthink/thinkphp": "dev-master",
"mustangostang/spyc": "0.5.*@dev"
}
}
2. Installation Package
# composer install
3. Create index. php
$ Loader = require 'vendor/autoload. php ';
// Application entry file
// Check the PHP Environment
If (version_compare (PHP_VERSION, '5. 3.0 ',' <') die ('require PHP> 5.3.0! ');
// Enable the debugging mode. We recommend that you enable the annotation of the deployment phase in the development phase or set it to false.
Define ('app _ debug', True );
// Define the application directory
Define ('app _ path', './Application /');
// Define the configuration format
Define ('conf _ EXT ','. yaml ');
Function yaml_parse_file ($ file ){
Return Spyc: YAMLLoad ($ file );
}
// Introduce the ThinkPHP entry file
Require './vendor/topthink/thinkphp/ThinkPHP. php ';
// It's so simple that no code is needed in the end of ^_^
4. Done.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB