vagrant@ubuntu-xenial:/var/www/test$ cat /proc/version
Linux version 4.4.0-161-generic (buildd@lcy01-amd64-018) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #189-Ubuntu SMP Tue Aug 27 08:10:16 UTC 2019
vagrant@ubuntu-xenial:/var/www/test$ php -v
PHP 7.1.0 (cli) (built: Feb 26 2021 04:41:12) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
git clone https://github.com/laruence/yaconf.git
cd yaconf
/usr/bin/phpize7.0 #我是将phpize安装到了该位置 就用你自己安装的位置就行
./configure --with-php-config=/usr/bin/php-config #后边写你自己php-config所在的位置
make -j && make install
在PHP.ini中配置
extension=yaconf.so # 导入扩展
yaconf.directory=/var/www/zip/config # 配置文件目录, 这个配置不能通过ini_set指定, 因为必须在PHP启动的时候就确定好.
yaconf.check_delay=60 # 多久(秒)检测一次文件变动, 如果是0就是不检测, 也就是说如果是0的时候, 文件变更只能通过重启PHP重新加载
foo="bar"
phpversion=PHP_VERSION
env=${HOME}
arr.0=1
arr.1=2
map2.foo.name=yaconf
map2.foo.year=2015
[parent]
parent="base"
children="NULL"
[children : parent]
children="children"
<?php
//获取配置 mixed Yaconf::get(string $name, mixed $default = NULL)
//检查配置是否存在 bool Yaconf::has(string $name)
print_r(\Yaconf::get('db'));
vagrant@ubuntu-xenial:/var/www/test$ php index.php
Array
(
[foo] => bar
[phpversion] => 7.1.0
[env] => /home/vagrant
[arr] => Array
(
[0] => 1
[1] => 2
)
[map2] => Array
(
[foo] => Array
(
[name] => yaconf
[year] => 2015
)
)
[parent] => Array
(
[parent] => base
[children] => NULL
)
[children] => Array
(
[parent] => base
[children] => children
[a] => 1
)
)