Maison > Article > développement back-end > soap扩展编译,加载及动态加载
#soap扩展
编译soap.so扩展~
SOAP扩展
进入安装原php的源码目录,
cd ext
cd soap
phpize
./configure --with-php-config=/var/php/bin/php-config (一定要有php-config这个文件的路径,不然会报错!)
make
就会在PHPDIR/ext/soap/modules/下生成soap.so的文件
php -i | grep ini 找到php.ini file
vi 那个php.ini
找到extension_dir = "/usr/lib/php/extensions"
将编译的soap.so放到里面
添加php.ini
extension=soap.so
[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=1
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir="/tmp"
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400
查看php -i | 是否安装成功
重启web服务
service nginx restart
service php-fpm stop
service php-fpm start
#可惜由于影响到先有程序...只能动态加载扩展
程序动态加载模块
if (!extension_loaded('soap')) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { dl('soap.dll'); ini_set('soap.wsdl_cache_dir',"C:\WINDOWS\Temp"); } else { dl('soap.so'); ini_set('soap.wsdl_cache_dir',"/tmp"); } ini_set('soap.wsdl_cache_enabled','1'); ini_set('soap.wsdl_cache_ttl',86400); }
其他常用扩展函数
extension_loaded('soap')//是否加载了soap扩展
dl('soap.so');//加载soap扩展
ini_set('soap.wsdl_cache_dir',"/tmp");//设置扩展参数
array get_extension_funcs ( string $module_name )
array get_loaded_extensions ([ bool $zend_extensions= false ] )