Home >Backend Development >PHP Tutorial >Introduction to Yaconf and installation and configuration instructions (Windows+Linux)
Generally, programmer projects use PHP files for configuration. There may be more than a dozen or even dozens of .php configuration files in a config directory, which contain various arrays, which results in The parsing of configuration files consumes a lot of performance. Yaconf can avoid parsing the configuration file every time it is requested, which is efficient and improves performance. This article will introduce yaconf to you and teach you how to install and configure yaconf. Friends who are interested can take a look. I hope it will be helpful to you.
Introduction to yaconf
It uses a separate configuration directory (specified in yaconf.directory), It is not together with the code. When PHP starts, it processes all the configurations to be processed, and then these configurations will reside in memory and live and die with the life cycle of PHP. It avoids parsing the configuration file and configuration every time it is requested. After the directory and code are separated, a configuration management background can be used to achieve unified management of the configuration. If the configuration changes, it will reload without restarting (the frequency of detection is controlled by yaconf.check_delay). It supports a variety of configuration types , including strings, arrays, sections, and section inheritance, and you can also directly write PHP constants and environment variables in the configuration.
Installation and Configuration
1. Windows
Windows 10 environment configuration
phpStudy integrated environment
Extension download address: http://pecl.php.net/package/yaconf
Select the latest version: http ://pecl.php.net/package/yaconf/1.0.7/windows
A version based on the local environment rules
Copy the decompressed php_yaconf.dll file to D:\phpStudy\PHPTutorial\php\php-7.0.12-nts\ext Directory
Modify the php.ini configuration file and add the following extension
extension=php_yaconf.dll
Configure yaconf
[yaconf] yaconf.directory="D:\phpStudy\Yaconf" // 配置文件的目录位置 yaconf.check_delay=60 // 配置文件的更新时间
Restart all services and use php probe to check whether the configuration is installed successfully
The above means the installation is successful
2. Linux
git clone https://github.com/laruence/yaconf.git cd yaconf/ phpize ./configure --with-php-config=/usr/local/php-7.2/bin/php-config sudo vim /usr/local/php-7.2/etc/php.ini ## 添加 extension=yaconf.so sudo systemctl restart php-fpm.service
Related tutorials: PHP video tutorial
The above is the detailed content of Introduction to Yaconf and installation and configuration instructions (Windows+Linux). For more information, please follow other related articles on the PHP Chinese website!