THINKPHP支持YAML配置文件的设置方法_PHP
为什么要用 yaml
因为 Yaml 简单,而且对人类友好;
Yaml: http://www.yaml.org/
在哪里会用到?
最基本的,在 ThinkPHP 的配置文件里面就可以选择 Yaml 的格式,你是愿意写 Yaml 的简洁格式配置呢?还是愿意写又长又臭又难写的 PHP array 呢?
http://document.thinkphp.cn/manual_3_2.html#config_format
问题来了
于是,我把配置格式改为 Yaml:
代码如下:
// /index.php
// 定义配置文件的格式为 yaml
define('CONF_EXT', '.yaml');
然后把 Application 目录下面的 config.php 全部改为 config.yaml。
这个时候,报错:
代码如下:
Class ‘Spyc' not found 错误位置 FILE: D:\app\think\ThinkPHP\Common\functions.php LINE: 90
然后找,发现这一段:
代码如下:
/**
* 解析yaml文件返回一个数组
* @param string $file 配置文件名
* @return array
*/
if (!function_exists('yaml_parse_file')) {
function yaml_parse_file($file) {
vendor('spyc.Spyc');
return Spyc::YAMLLoad($file);
}
}
貌似引入 Spyc 这个库没找到。
找了一下,Spyc 在这里:https://github.com/mustangostang/spyc/
然后,这个 vendor 是什么东东?
看这里:http://document.thinkphp.cn/manual_3_2.html#autoload
结论:
在上面的 Git 里面下载 Spyc.php 放进 /ThinkPHP/Library/Vendor/spyc/ 目录下,就一切正常!Done with the right way!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

MyBatisGenerator is a code generation tool officially provided by MyBatis, which can help developers quickly generate JavaBeans, Mapper interfaces and XML mapping files that conform to the database table structure. In the process of using MyBatisGenerator for code generation, the setting of configuration parameters is crucial. This article will start from the perspective of configuration parameters and deeply explore the functions of MyBatisGenerator.
