What can a yaconf do?
1. It uses a separate configuration directory (specified in yaconf.directory), and the code is detached.
2. It handles all the configuration to be processed when PHP is started, then the configuration will reside in memory, as the life cycle of PHP survives. Avoid parsing the configuration file each time the request is made.
3. All the configuration content is immutable, this can be aided by the fork of the cow, reduce memory consumption, and in the configuration, almost no need any memory copy, there will be no unnecessary reference count increase or decrease
4. Most importantly, after the configuration directory and code separation, you can use a configuration management background, to achieve unified management of the configuration.
5. It supports (for non-ZTS) configuration change reload, that is, if the configuration changes (recommended change configuration must use MV, do not use CP), it will reload, do not need to restart (detection frequency by Yaconf.check_delay control).
6. It supports rich configuration types, including strings, arrays, sections, sub-sections, and can also write PHP constants and environment variables directly in the configuration.
Two-Installation
wget http://pecl.php.net/get/yaconf-1.0.2.tgz
Tar zxvf yaconf-1.0.2.tgz
CD yaconf-1.0.2
Phpize
./configure--with-php-config=php-config
Make && sudo make install
PHP.ini Configuration
Extension=yaconf.so
yaconf. directory= configuration file directory
Yaconf.check_delay=0
(How long (seconds) to detect a file change, if it is 0 is not detected, that is, if it is 0, file changes can only be restarted by restarting PHP reload)
Three use
Yaconf's configuration file extension is INI file such as Config.ini
Configuration content
Line=test
[Cheezu]
Db=server_shuchuang
[YLC]
Db=server_yiliangche
PHP get
Yaconf::get (' Config.line ');
Yaconf::get (' config.cheezu.db ');
Yaconf::get (' config.ylc.db ');
Where config is the name of the Config.ini file
Config.ini Content
Dbmasterhost= "127.0.0.1"
dbslavehost1= "127.0.0.1"
dbuser= "Server"
Dbpasswd= "8492107"
Dbport= "3306"
Memhost= "C91dcc9308bf11e4.m.cnqdalicm9pub001.ocs.aliyuncs.com"
Memuser= "C91dcc9308bf11e4"
Mempasswd= "O2o20131203_"
Memport= "11211"
Upyunbucketname= "Shuchuangxinxi"
Upyunuser= "Gaosimeng"
Upyunpasswd= "Womeibaobao"
[YLC]
Dbmasterhost= "127.0.0.1"
dbslavehost1= "127.0.0.1"
dbuser= "Server"
Dbpasswd= "8492107"
Dbport= "3306"
Memhost= "C91dcc9308bf11e4.m.cnqdalicm9pub001.ocs.aliyuncs.com"
Memuser= "C91dcc9308bf11e4"
Mempasswd= "O2o20131203_"
Memport= "11211"
Upyunbucketname= "Yiliangche"
Upyunuser= "Ylcupyun"
Upyunpasswd= "SDPKADDKSLS8SGL"
[Auth]
host=http://127.0.0.1:8507
php.ini file
Extension=memcached.so
Extension=zip.so
Extension=redis.so
Extension=ftp.so
Extension=yaconf.so
Yaconf.directory=/usr/local/php-7.0.4/etc/yaconf
Yaconf.check_delay=0
Extension=yar.so
Extension=msgpack.so
Reference articles
Http://pecl.php.net/package/yaconf
Http://www.laruence.com/2015/06/12/3051.html
This article is from the "HD Code" blog, please be sure to keep this source http://benchmarking.blog.51cto.com/12343634/1877764
Configuration management extensions for YACONF-PHP7