歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> centos安裝Yaconf

centos安裝Yaconf

日期:2017/3/6 9:10:57   编辑:學習Linux

centos安裝Yaconf


centos安裝Yaconf


什麼是Yaconf?看過來:

  • http://www.laruence.com/2015/06/12/3051.html

安裝:

git clone https://github.com/laruence/yaconf.gitcd yaconfphpize./configure --with-php-config=/usr/local/php/bin/php-config makemake install

配置PHP.ini:

vi /usr/local/php/etc/php.ini加入:[Yaconf]extension=yaconf.so         #擴展引用yaconf.directory=/home/web/conf     #conf文件所在目錄yaconf.check_delay=100          #心跳檢查時間,若為0則不檢查,但如果有修改,需重啟PHP

運行:

– PHP加載時,會先查找/home/web/conf內所有ini文件,並解析; – 解析的內容會常駐內存,在PHP代碼中和調用php.ini的值一樣的形式去調用;

設置ini文件

/home/web/conf/test.ini

foo="bar"phpversion=PHP_VERSION

方法,只有get和has兩個方法:

#讀取值:echo Yaconf::get("test.foo"); //test是配置文件名字#判斷是否有該項設置echo Yaconf::has("test.foo"); //test是配置文件名字

特殊定義–數組:

定義:

arr[]=1arr.1=2

讀取:

Yaconf::get("test.arr.1");    #讀取指定項Yaconf::get("test.arr");      #讀出數組

特殊定義–map類型

定義:

;可以使用分號來寫注釋map2.foo.name=yaconfmap2.foo.year=2015

讀取:

Yaconf::get("test.map2.foo.name");

特殊定義–分組

定義:

[parent]parent="base"children="NULL"[children:parent]children="children"

讀取:

Yaconf::get("test"); #返回的是一個KV格式的數組,也可以用.號間隔訪精確訪問

http://www.bkjia.com/Linuxjc/1156107.html TechArticle

Copyright © Linux教程網 All Rights Reserved