PHP-CPP是一个用于开发PHP扩展的C++库。它提供了一套详实易用的类,用于开发PHP扩展。详细文档说明:http://www.php-cpp.com
如果在安装过程中报下面的错误:
g++ -Wall -c -g -std=c++11 -fpic -o shared/common/modifiers.o common/modifiers.cpp
cc1plus: error: unrecognized command line option “-std=c++11″
make: *** [shared/common/modifiers.o] Error 1
在安装PHP-CPP过程中会报如下错误:
g++ -Wall -c -g -std=c++11 -fpic -o common/modifiers.o common/modifiers.cpp
g++ -Wall -c -g -std=c++11 -fpic -o common/streambuf.o common/streambuf.cpp
g++ -Wall -c -g -std=c++11 -fpic php-config --includes -o zend/base.o zend/base.cpp
In file included from zend/includes.h:112:0,
from zend/base.cpp:8:
zend/objectimpl.h: In constructor hp::ObjectImpl::ObjectImpl(zend_class_entry*, Php::Base*)
zend/objectimpl.h:88:95: error: val_property_ctor鈥was not declared in this scope
zend_hash_copy(_mixed->php.properties, &entry->default_properties, (copy_ctor_func_t) zval_property_ctor, &tmp, sizeof(zval*));
^
make: *** [zend/base.o] Error 1
解决办法如下:
1. 下载对应的php源码
2. 解压php源码,将源码目录下的zend目录拷贝到php-cpp源码目录下,用以替换php-cpp自带的zend
3. 重新编译安装php-cpp
安装过程如下:
# git clone https://github.com/andot/PHP-CPP.git
# cd PHP-CPP/
# mv zend zend_org
# cp -Rf /path/to/php_source/zend ./
# make
# make install
# cp libphpcpp.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
# vim /usr/local/php/etc/php.ini
extension = libphpcpp.so
1
2
3
4
5
6
7
8
9
# git clone https://github.com/andot/PHP-CPP.git
# cd PHP-CPP/
# mv zend zend_org
# cp -Rf /path/to/php_source/zend ./
# make
# make install
# cp libphpcpp.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/
# vim /usr/local/php/etc/php.ini
extension=libphpcpp.so