GithubHelp home page GithubHelp logo

laruence / yaconf Goto Github PK

View Code? Open in Web Editor NEW
1.0K 1.0K 184.0 143 KB

A PHP Persistent Configurations Container

License: Other

C 76.30% PHP 21.91% Shell 0.13% M4 1.04% JavaScript 0.62%
c configuration-management php yaconf

yaconf's People

Contributors

cmb69 avatar fenying avatar hi-iwi avatar huanghantao avatar laruence avatar leeeboo avatar lzyim avatar qishibo avatar remicollet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yaconf's Issues

Class 'Yaconf' not found

I've seen in the official documentation that yaconf is a PHP core that doesn't need to be installed, but it does need to be installed when it's actually used

PHP 7.4 support

Build fails

/dev/shm/BUILD/php74-php-pecl-yaconf-1.0.8/NTS/yaconf.c: In function 'php_yaconf_hash_destroy':
/dev/shm/BUILD/php74-php-pecl-yaconf-1.0.8/NTS/yaconf.c:124:23: error: 'HASH_FLAG_INITIALIZED' undeclared (first use in this function); did you mean 'HASH_FLAG_UNINITIALIZED'?
  if (((ht)->u.flags & HASH_FLAG_INITIALIZED)) {
                       ^~~~~~~~~~~~~~~~~~~~~
                       HASH_FLAG_UNINITIALIZED
/dev/shm/BUILD/php74-php-pecl-yaconf-1.0.8/NTS/yaconf.c:124:23: note: each undeclared identifier is reported only once for each function it appears in
/dev/shm/BUILD/php74-php-pecl-yaconf-1.0.8/NTS/yaconf.c: In function 'zm_startup_yaconf':
/dev/shm/BUILD/php74-php-pecl-yaconf-1.0.8/NTS/yaconf.c:530:18: warning: unused variable 'c' [-Wunused-variable]
    unsigned char c;
                  ^
make[1]: *** [Makefile:193: yaconf.lo] Error 1

php-7.3.1编辑错误

/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c: In function ‘php_yaconf_hash_init’:
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:90:15: error: lvalue required as left operand of assignment
GC_FLAGS(ht) |= IS_ARRAY_IMMUTABLE;
^~
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:91:15: error: lvalue required as left operand of assignment
GC_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS;
^~
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:95:19: error: ‘HASH_FLAG_APPLY_PROTECTION’ undeclared (first use in this function); did you mean ‘_SC_MEMORY_PROTECTION’?
GC_FLAGS(ht) &= HASH_FLAG_APPLY_PROTECTION;
^~~~~~~~~~~~~~~~~~~~~~~~~~
_SC_MEMORY_PROTECTION
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:95:19: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:98:18: error: lvalue required as left operand of assignment
GC_REFCOUNT(ht) = 2;
^
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:103:23: error: ‘IS_TYPE_COPYABLE’ undeclared (first use in this function); did you mean ‘Z_OPT_COPYABLE’?
Z_TYPE_FLAGS_P(zv) = IS_TYPE_COPYABLE;
^~~~~~~~~~~~~~~~
Z_OPT_COPYABLE
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c: In function ‘php_yaconf_str_persistent’:
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:149:16: error: lvalue required as left operand of assignment
GC_FLAGS(key) |= IS_STR_INTERNED | IS_STR_PERMANENT;
^

/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c: In function ‘php_yaconf_zval_persistent’:
/usr/local/src/php-7.3.1/ext/yaconf/yaconf.c:171:8: error: ‘IS_CONSTANT’ undeclared (first use in this function); did you mean ‘RT_CONSTANT’?
case IS_CONSTANT:
^~~~~~~~~~~
RT_CONSTANT
Makefile:194: recipe for target 'yaconf.lo' failed
make: *** [yaconf.lo] Error 1

求解答

在 PHP_MINIT_FUNCTION 里面更新配置到 ini_containers 变量,只读取配置文件一次。
在 PHP_RINIT_FUNCTION 里面,如果检测到配置文件发生变化了,则每个进程创建后,都需要从这里读取配置文件一次来更新每个进程的 ini_containers 变量。

这样理解对吗? 谢谢啦~

memory leaks when config file has same key

content of config file:

user.name = "Jason"
user.name = "Jason"

➜ yaconf git:(master) ✗ ZEND_DONT_UNLOAD_MODULES=1 USE_ZEND_ALLOC=0 valgrind --leak-check=full php7 test.php

==27003== Memcheck, a memory error detector
==27003== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==27003== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==27003== Command: php7 test.php
==27003== 
==27003== 
==27003== HEAP SUMMARY:
==27003==     in use at exit: 16,955 bytes in 69 blocks
==27003==   total heap usage: 20,416 allocs, 20,347 frees, 2,537,228 bytes allocated
==27003== 
==27003== 32 bytes in 1 blocks are definitely lost in loss record 13 of 37
==27003==    at 0x4C27A2E: malloc (vg_replace_malloc.c:270)
==27003==    by 0xDFBB9F5: __zend_malloc (zend_alloc.h:188)
==27003==    by 0xDFBBA78: zend_string_alloc (zend_string.h:121)
==27003==    by 0xDFBBB0E: zend_string_init (zend_string.h:157)
==27003==    by 0xDFBC2CD: php_yaconf_zval_persistent (yaconf.c:142)
==27003==    by 0xDFBC545: php_yaconf_simple_parser_cb (yaconf.c:195)
==27003==    by 0xDFBCD55: php_yaconf_ini_parser_cb (yaconf.c:339)
==27003==    by 0x7E742E: ini_parse (zend_ini_parser.y:293)
==27003==    by 0x7E6AA4: zend_parse_ini_file (zend_ini_parser.y:209)
==27003==    by 0xDFBD67C: zm_startup_yaconf (yaconf.c:503)
==27003==    by 0x832E1C: zend_startup_module_ex (zend_API.c:1854)
==27003==    by 0x832E7E: zend_startup_module_zval (zend_API.c:1869)

修改配置重新加载建议

看了yaconf,如果中间修改了配置,系统会自动检测重新加载,其实配置大部分时间都不会去动,一直有个检测在跑其实也有一定的资源消耗,虽然很小。建议弄成触发式的重新加载,之后有一些yaconf管理后台的话也可以手动重新加载。小小建议😄

windows7下yaconf.check_delay无效

windows7,x64,PHP7.0.14-TS,

[yaconf]
extension=php_yaconf.dll
yaconf.check_delay=100

phpinfo显示为:
yaconf config last check time -

yaconf.check_delay无效,请大大指点 要怎么修复这个问题

开发环境下支持

我有多个开发环境dev1 、dev2 ...
我现在的做法,入口文件加了个常量APP_ENV = 'dev1';自己加了个Appconf::get 在方法里调用
Yaconf::get(APP_ENV . '_' . $key);
然后配置文件名都是这样 dev1_common.ini 、dev2_common.ini ..

但在各开发环境中,大部分参数都是一样的,只有配置里service_getway里面对应的服务参数不一样,每次修改,都要修改每个文件。
能否加入跨文件的Section继承
或者从文件名上的"."号已可以参与到数据的覆盖上如: dev1_common.service_getway.ini就可以给dev1_common.ini的配置文件补充service_getway部分的数据
或单文件内[dev1.service_getway: base.service_getway] 多层级的继承

PHP7.2.10 设置目录无法启动

如果为directory设置一个不存在的目录,PHP可以启动,如果一个存在的目录,不管是空目录还是有INI文件,PHP都启动不起来, 7.1.x没发现这问题。我是在cli模式下测试的

windows10 64

PHP 7.2.10 (cli) (built: Sep 13 2018 00:47:25) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

php配置

extension=php_yaconf
yaconf.directory = "D:/php/test"
yaconf.check_delay=5

Found a cause of php-fpm process crash situation

I follow the steps below and found that the php-fpm process can not parse the php file normally, but the process is not broken, but it can not handle the request. Through the browser request to get a 502 error.

  1. Install the latest version of yaconf
  2. Go to the php.ini file to set the path
  3. But the path does not exist
  4. Create this path manually
  5. There was a strange question that php-fpm could not work properly.

Whether it is due to the problem of the module itself.

总觉得ini配置文件,表达能力还是弱了点

要做个屏蔽词检测的部件,会将几千个屏蔽词生成类似这样的接口
[ 'f' => [ 'u' => [ 'a' => '$end', 'c' => [ 'k' => '$end' ] ] ] ]
想用Yaconf做配置,但是生成的结构不太容易导出,还有一个中文特殊字符等问题,如果能支持json或者php做配置文件就更好了

获取配置信息时提示使用未定义常量,php版本7.3.15

文件内容:

 vi foo.ini

name="yaconf"                  ;string
year=2020                      ;number
features[]="fast"              ;map
features.1="light"
features.plus="zero-copy"
features.constant=PHP_VERSION  ;PHP constants

提示如下:

php -r "var_dump(Yaconf::get("foo"));"
PHP Warning:  Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1

Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1
array(3) {
  ["name"]=>
  string(6) "yaconf"
  ["year"]=>
  string(4) "2020"
  ["features"]=>
  array(4) {
    [0]=>
    string(4) "fast"
    [1]=>
    string(5) "light"
    ["plus"]=>
    string(9) "zero-copy"
    ["constant"]=>
    string(6) "7.3.15"
  }
}
php -r "var_dump(Yaconf::get("foo.name"));"
PHP Warning:  Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1

Warning: Use of undefined constant foo - assumed 'foo' (this will throw an Error in a future version of PHP) in Command line code on line 1
PHP Warning:  Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Command line code on line 1

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Command line code on line 1
NULL

PHP73 编译扩展时出问题,pecl 装也会有这个错误

make的时候出现这个异常了

mkdir .libs
 cc -I. -I/app/yaconf-yaconf-1.0.6 -DPHP_ATOM_INC -I/app/yaconf-yaconf-1.0.6/include -I/app/yaconf-yaconf-1.0.6/main -I/app/yaconf-yaconf-1.0.6 -I/usr/include/php7 -I/usr/include/php7/main -I/usr/include/php7/TSRM -I/usr/include/php7/Zend -I/usr/include/php7/ext -I/usr/include/php7/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /app/yaconf-yaconf-1.0.6/yaconf.c  -fPIC -DPIC -o .libs/yaconf.o
/app/yaconf-yaconf-1.0.6/yaconf.c: In function 'php_yaconf_hash_init':
/app/yaconf-yaconf-1.0.6/yaconf.c:92:15: error: lvalue required as left operand of assignment
  GC_FLAGS(ht) |= IS_ARRAY_IMMUTABLE;
               ^~
/app/yaconf-yaconf-1.0.6/yaconf.c:93:18: error: lvalue required as left operand of assignment
  GC_REFCOUNT(ht) = 2;
                  ^
/app/yaconf-yaconf-1.0.6/yaconf.c:98:23: error: 'IS_TYPE_COPYABLE' undeclared (first use in this function)
  Z_TYPE_FLAGS_P(zv) = IS_TYPE_COPYABLE;
                       ^~~~~~~~~~~~~~~~
/app/yaconf-yaconf-1.0.6/yaconf.c:98:23: note: each undeclared identifier is reported only once for each function it appears in
/app/yaconf-yaconf-1.0.6/yaconf.c: In function 'php_yaconf_str_persistent':
/app/yaconf-yaconf-1.0.6/yaconf.c:144:16: error: lvalue required as left operand of assignment
  GC_FLAGS(key) |= IS_STR_INTERNED | IS_STR_PERMANENT;
                ^~
/app/yaconf-yaconf-1.0.6/yaconf.c: In function 'php_yaconf_zval_persistent':
/app/yaconf-yaconf-1.0.6/yaconf.c:166:8: error: 'IS_CONSTANT' undeclared (first use in this function)
   case IS_CONSTANT:
        ^~~~~~~~~~~
make: *** [Makefile:194: yaconf.lo] Error 1

请问配置引用应该怎么做?

比如我有一个域名的配置,
env.ini

domain=xxxx.weibo.com

这时如果我想在同一个配置文件或别的配置文件中(不是在PHP代码中)引用这个domain值,要怎么做呢?因为我会有很多不经常变的配置比如,播放地址、管理后台地址什么的。虽然也可以一遍一遍的写,但在一台多人使用的开发机上配置不同域名的开发环境就比较麻烦了。

希望鸟哥能给指条路

希望支持以对象形式访问

我们项目想从Yaf的Yaf_Config_Ini转向yaconf配置文件,期间遇到一个问题,如果yaconf获取的一个节点包含子节点,返回的是一个数组,只能用$config['xxx']访问。

而Yaf_Config_ini返回的是一个Yaf_Config_ini对象,可以用$config['xxx']访问,也可以用$config->xxx访问。

希望返回值是一个类似于Yaf_Config_ini的对象,可以用数组访问,也可用对象访问,这样改动不是很大

不会出现与文件不完全一致的时候吗?

a.ini(前) a.ini(修改中) a.ini(后)
a=1 a=2 a=2
b=1 b=1 b=2

在yaconf检测到需要修改的时候直接修改了mtime,内容只修改了a没修改b,但是有别的请求读取的时候mtime已经更新,不会去读文件,读取出来的a和b不会是跟文件不一致的吗?复制一个新的临时变量,更新为文件的内容,再替换指针保证变量的内容跟文件的保持一致,会不会好一点?

yaconf 内存溢出bug

php 版本 7.0.7
yaconf 版本 1.0.2

运行下面的代码 PHP 进程的内存会一直增加。

while(true){
$acc = yaconf::get('topic.time_line');
array_walk_recursive($acc, function ($item) {
});
var_dump(Memory_get_usage());
}

这样内存会一直增长。

php 7.3.4 make error

鸟哥,今天编译时发生下面这个错误
/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c: In function ‘php_yaconf_hash_init’:
/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:90:15: error: lvalue required as left operand of assignment GC_FLAGS(ht) |= IS_ARRAY_IMMUTABLE;
^~/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:91:15: error: lvalue required as left operand of assignment
GC_FLAGS(ht) |= HASH_FLAG_STATIC_KEYS; ^~/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:95:19: error: ‘HASH_FLAG_APPLY_PROTECTION’ undeclared (first use in this function); did you mean ‘_SC_MEMORY_PROTECTION’?
GC_FLAGS(ht) &= ~HASH_FLAG_APPLY_PROTECTION; ^~~~~~~~~~~~~~~~~~~~~~~~~~
_SC_MEMORY_PROTECTION/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:95:19: note: each undeclared identifier is reported only once for each function it appears in
/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:98:18: error: lvalue required as left operand of assignment GC_REFCOUNT(ht) = 2;
^
/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:103:23: error: ‘IS_TYPE_COPYABLE’ undeclared (first use in this function); did you mean ‘Z_OPT_COPYABLE’?
Z_TYPE_FLAGS_P(zv) = IS_TYPE_COPYABLE; ^~~~~~~~~~~~~~~~
Z_OPT_COPYABLE/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c: In function ‘php_yaconf_str_persistent’:
/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:149:16: error: lvalue required as left operand of assignment GC_FLAGS(key) |= IS_STR_INTERNED | IS_STR_PERMANENT;
^~/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c: In function ‘php_yaconf_zval_persistent’:
/home/tangchao/Downloads/yaconf-yaconf-1.0.7/yaconf.c:171:8: error: ‘IS_CONSTANT’ undeclared (first use in this function); did you mean ‘RT_CONSTANT’?
case IS_CONSTANT: ^~~~~~~~~~~
RT_CONSTANTmake: *** [Makefile:194:yaconf.lo] 错误 1

yaconf在php7.3下安装失败

/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c: In function ‘php_yaconf_hash_init’:
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c:92:15: error: lvalue required as left operand of assignment
GC_FLAGS(ht) |= IS_ARRAY_IMMUTABLE;
^
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c:93:18: error: lvalue required as left operand of assignment
GC_REFCOUNT(ht) = 2;
^
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c:98:23: error: ‘IS_TYPE_COPYABLE’ undeclared (first use in this function)
Z_TYPE_FLAGS_P(zv) = IS_TYPE_COPYABLE;
^
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c:98:23: note: each undeclared identifier is reported only once for each function it appears in
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c: In function ‘php_yaconf_str_persistent’:
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c:144:16: error: lvalue required as left operand of assignment
GC_FLAGS(key) |= IS_STR_INTERNED | IS_STR_PERMANENT;
^
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c: In function ‘php_yaconf_zval_persistent’:
/home/webb.m/source/yaconf-yaconf-1.0.6/yaconf.c:166:8: error: ‘IS_CONSTANT’ undeclared (first use in this function)
case IS_CONSTANT:
^
make: *** [yaconf.lo] Error 1

我用的php7.3 系统是centos centos-release-7-5.1804.el7.centos.x86_64
我使用了pecl 和源码安装都出现了同样的问题。

能否支持数字类型输出?

[redis]
default.host=127.0.0.1
default.port=6379
default.timeout=1
default.reserved=NULL
default.interval=100
default.auth=123456

上述 比如 port 配置成了数字6379,取出来的是字符串6379,这样在PHP7强类型情况下

declare(strict_types=1);

代码就会报错

$redis->connect(
            APP_CONFIG['redis'][$db]['host'],
            APP_CONFIG['redis'][$db]['port'],
            APP_CONFIG['redis'][$db]['timeout'],
            APP_CONFIG['redis'][$db]['reserved'],
            APP_CONFIG['redis'][$db]['interval']
        );
Fatal error: Uncaught TypeError: Redis::connect() expects parameter 2 to be int, string given

windows下php7.2的1.06和1.07版本都不支持盘符

windows下php7.2的1.06和1.07版本
yaconf.directory配置盘符时php无法启动且没有php的错误日志
换成类似Linux的/开头后可正常启动php,但无法读取配置(windows下是盘符开头)
希望鸟哥更新一下

fpm 下 mtime 无法更新

fpm下

image

cli 下

$ php -v
PHP 7.2.10 (cli) (built: Oct 11 2018 22:20:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend Technologies


$ php -i | grep -A10 yaconf
yaconf
yaconf support => enabled
version => 1.0.7
yaconf config last check time => Sat Oct 20 17:57:19 2018
parsed filename => mtime
test.ini => Sat Oct 20 17:45:03 2018
Directive => Local Value => Master Value
yaconf.check_delay => 5 => 5
yaconf.directory => /webroot/.Yaconf => /webroot/.Yaconf


$ stat test.ini
File: test.ini
Size: 10 Blocks: 8 IO Block: 4096 regular file
Device: 811h/2065d Inode: 932512 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ bobo) Gid: ( 1000/ bobo)
Access: 2018-10-20 17:33:05.924045838 +0800
Modify: 2018-10-20 17:45:03.085220849 +0800
Change: 2018-10-20 17:45:03.085220849 +0800
Birth: -

不重启php-fpm,能reload数据么

目前有些游戏的模版表数据存在yac里面,yaconf是不是性能更好,不重启 php-fpm能reload数据么
类似 opcache那种 opcache_reset() 功能

请问有必要使用 yaconf 替代 yaf 中的默认 config 机制吗?

鸟哥好,

首先,在使用 yaf 时, 当 yaf.cache_config = 1,采用的 config 机制是否与 yaconfig 是相同的?

如果使用默认的 yaf.cache_config = 0,当我需要使用 yaconfig 做配置管理时,应该怎样执行 Yaf_Application 的初始化?

$application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");

//尝试过做如下修改
$application = new Yaf_Application( Yaconf::get("application") );  

//yaconf 获取的 application.ini 与 yaf 下 /conf/application.ini 一致,
//但是抛异常了 “Expected an array of application configure”。

看了下 yaf 的文档,

config
关联数组的配置, 或者一个指向ini格式的配置文件的路径的字符串, 或者是一个Yaf_Config_Abstract实例

有点困扰。

是否只能默认采用加载 "/conf/application.ini" 的方式(application.ini 为空文件),然后在 Bootstrap 里定义 _initConfig(), 然后将配置文件通过 yaconf 加载并注册到 yaf 中?

public function _initConfig() {
    //Yaf_Registry::set('config', Yaf_Application::app()->getConfig());
    Yaf_Registry::set('config', Yaconf::get("application"));
}

//貌似这样依然会抛出异常 “Initialization of application config failed”

Yaconf 加入 数据库连接池功能

@laruence 鸟哥,您好!

一个不成熟的想法:数据库每次连接的成本有点高,如果把数据库连接池的功能加入Yaconf,填补了fpm的一大短板,我想收益蛮大的。

不知是否可以考虑?
感谢!

配置yaconf.directory 后segmentation fault

➜ tail -f -n 10 etc/php.ini
[redis]
extension="redis.so"

[ast]
extension=ast.so

[Yaconf]
extension=yaconf.so
yaconf.directory="/home/www/yaconf"
yaconf.check_delay=1

➜ php -v
[1] 13598 segmentation fault php -v

// -------
环境
Mac Pro - EI Captian 10.11.5
PHP 7.0.5 (cli) (built: Apr 11 2016 02:07:04) ( NTS DEBUG )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

Linux 环境是正常的
CentOS 7.0
PHP 7.0.6 (cli) (built: May 17 2016 17:11:07) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

//// -----
Mac 开发机 多开了个 DEBUG

php5 能不能给支持一下

不公平啊,php5 能不能给支持一下。毕竟php7刚出来。所有项目都升级还有一段时间。有没有同样需求的?

关于搭建报错问个问题

你好,我搭建两次yaconf-1.0.1的,一次是编译安装,一次是pecl 安装,根据您的样例,但是报错了
Fatal error: Uncaught Error: Class 'Yaconf' not found in Command line code:1
我php是7.0.4的,我试着在php.ini里加了extension=yaconf.so 也不行

yaconf config last check time 没有根据 yaconf.check_delay 变化

php version: 7.1.4
yaconf version: 1.0.5
macOS 10.12.5

yaconf.check_delay = 5

在 phpinfo() 页面中,yaconf config last check time 每一秒跳一次,而不是 5 秒跳一次。
而且时间会回跳,比如 11:39:48 -> 11:39:49 -> 11:39:46 类似这样。

用 Atom (我试了这个)更改了 yaconf.directory 下文件的内容,不会被检测出来改动,获取不到新的值;
用 vim 更改之后,可以被检测出来改动,没问题。

Segmentation fault $php_fpm_BIN --daemonize $php_opts

安装好扩展并开启扩展,重启fpm进程时遇到错误:

Starting php-fpm /etc/init.d/php-fpm7: line 53: 17443 Segmentation fault      $php_fpm_BIN --daemonize $php_opts

我使用php7.0.x,请帮助修复这个问题。

安装报错,AC_CONFIG_HEADERS not found in configure.in

/usr/local/bin/phpize: line 61: /usr/local/Library/Homebrew/shims/super/sed: No such file or directory
/usr/local/bin/phpize: line 62: /usr/local/Library/Homebrew/shims/super/sed: No such file or directory
/usr/local/bin/phpize: line 63: /usr/local/Library/Homebrew/shims/super/sed: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
/usr/local/bin/phpize: line 155: /usr/local/Library/Homebrew/shims/super/sed: No such file or directory
autoheader: error: AC_CONFIG_HEADERS not found in configure.in

请问扩展只能运行在CLI模式下吗?

您好,我在测试时,发现在CLI模式下可以正常使用,但网页端请求脚本则无法获取正确结果(网页获取phpinfo可以正常显示yaconf扩展相关配置项,可以确定php.ini配置没什么大问题),请问在使用方式上有限制吗?还是需要进行其他的设置?

【我测试环境】
apache2.4 + php和yaconf扩展都是采用源码编译的方式(php版本为7.0.9,yaconf为github上clone的最新代码[2016.12.19])。

php7 编译:

./configure -prefix=/usr/local/php7 --with-apxs2=/usr/sbin/apxs --enable-fpm --enable-debug
make && make install

yaconf编译:

./configure --with-php-config=/usr/local/php7/bin/php-config
make && make install

php.ini配置文件:

[yaconf]
yaconf.directory=/tmp/yaconf

/tmp/yaconf目录下test.ini资源文件内容:

name="yaconf"
year=2016

php测试代码test.php:

var_dump(Yaconf::get('test'));

实验效果:

$php -f test.php
array(2) {
["name"]=>
string(4) "test"
["year"]=>
string(4) "2016"
}
通过网页访问test.php返回:
NULL

Broken build with 7.2.0-dev

Only a tracker (7.2.0 is really not close to release ;)

/dev/shm/BUILD/php72-php-pecl-yaconf-1.0.5/NTS/yaconf.c: In function 'php_yaconf_hash_init':
/dev/shm/BUILD/php72-php-pecl-yaconf-1.0.5/NTS/yaconf.c:95:23: error: 'IS_TYPE_IMMUTABLE' undeclared (first use in this function)
  Z_TYPE_FLAGS_P(zv) = IS_TYPE_IMMUTABLE;
                       ^~~~~~~~~~~~~~~~~
/dev/shm/BUILD/php72-php-pecl-yaconf-1.0.5/NTS/yaconf.c:95:23: note: each undeclared identifier is reported only once for each function it appears in
/dev/shm/BUILD/php72-php-pecl-yaconf-1.0.5/NTS/yaconf.c: In function 'zm_startup_yaconf':
/dev/shm/BUILD/php72-php-pecl-yaconf-1.0.5/NTS/yaconf.c:503:18: warning: unused variable 'c' [-Wunused-variable]
    unsigned char c;
                  ^
Makefile:194: recipe for target 'yaconf.lo' failed

一直读取不到配置文件

用的pecl install yaconf命令安装的,执行 ·· php -r 'var_dump(Yaconf::get("test"));' ·· 一直返回null,php.ini相关配置都加了。。可能是什么原因导致的呢?

Segfault during test suite with 7.1.0GA (TS)

Was ok with 7.1.0RC6...
NTS build are still ok

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Check for Yaconf [tests/002.phpt]
Check for Yaconf [tests/003.phpt]
Check for Yaconf with same keys [tests/007.phpt]
Check for Yaconf with pop entry [tests/008.phpt]
ISSUE #19 Memory leak on foreach and reference [tests/issue19.phpt]
=====================================================================

All with 'Termsig=11'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.