amfext for PHP5.3扩展的安装

1. 下载amfext
http://www.teslacore.it/wiki/index.php?title=AMFEXT

2. 编译安装前工作
对于Windows系统,请参考文章
对于Linux系统,需要修改源码amf.c才能在php5.3中make 通过
On line 1188, replace:
int deallocResult = (*struc)->refcount;
with
int deallocResult = Z_REFCOUNT_PP(struc);

On line 2674, replace:
newval->refcount--;
with
Z_DELREF_P(newval);

为了配合AMFPHP使用amfext,还需要做以下修改
Check your apache logs for the errors. If the log contains the following line:
‘Symbol not found: _ZVAL_ADDREF’
or
‘undefined symbol: ZVAL_ADDREF’.
After making above changes to amf.c, You also need to replace ZVAL_ADDREF with Z_ADDREF_P to solve the problem.


3. 开始编译安装
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install

生成amf.so

4.例子
虽然phpinfo显示安装成功,但是官方例子
$r = amf_encode("hello world",AMF_AS_STRING_BUILDER);  // ask to return a SB
echo("returned type: " . $r . "\n");
echo("returned length: " . amf_sb_length($r) . "\n");
$sb1 = amf_sb_new();
amf_sb_append($sb1,"prefix");  
amf_encode("hello world",0,"",$sb1);  // store the result into the provided SB
echo("returned type: " . $sb1 . "\n");
echo("returned length: " . amf_sb_length($sb1) . "\n");

AMF_AS_STRING_BUILDER始终提示未定义。

另外,amfphp自动识别amfext扩展是否安装,如果安装,它自动使用amfext编码解码,结果发现amfext安装后,amfphp就不能工作了,原因不明啊(调查中)!

你可能感兴趣的:(C++,c,linux,PHP,windows)