使用于PHP的App Engine加载BCMath或php.ini
I'm running the latest php-cgi from Arch Linux's repos. I enabled the BCMath module on php.ini and it works when I run php, php-cgi and php in Apache. However, when dev_appserver.py runs php, somehow it loses the configuration I set in php.ini. Causing both BCMath, soap and my locale settings to not load, causing:
dev_appserver.py --php_executable_path /usr/bin/php-cgi appengine-try-php
PHPEnvironmentError: The PHP runtime requires the "bccomp" function, which is not defined.
php-cgi -i | grep -i bcmath
returns BCMATH enabled.
php -i | grep -i bcmath
returns BCMATH enabled.
php -r "echo bccomp('1.0001', '1', 5);"
returns 1.
Is there any way to make dev_appserver.py load the module or php.ini?
我正在运行Arch Linux的回购中的最新php-cgi。 我在php.ini上启用了BCMath模块,当我在Apache中运行php,php-cgi和php时,它可以工作。 但是,当dev_appserver.py运行php时,它会以某种方式丢失我在php.ini中设置的配置。 导致BCMath,soap和我的语言环境设置无法加载,导致: p>
dev_appserver.py --php_executable_path / usr / bin / php-cgi appengine-try-php
PHPEnvironmentError :PHP运行时需要“bccomp”函数,该函数未定义。
code> pre>
php-cgi -i | grep -i bcmath code>返回BCMATH。 p>
php -i | grep -i bcmath code>返回BCMATH。 p>
php -r“echo bccomp('1.0001','1',5);” code>返回 1。 p>
有没有办法让dev_appserver.py加载模块或php.ini? p>
div>
google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/php/runtime.py
Supports loading a php.ini file from the project directory, as such you can just drop a php.ini file in the project directory. It will by default ignore the php.ini file in /etc/php/php.ini unlike all other instances of php. Here is the php.ini script I'm using. It likely has extra modules and modules that are missing compared to the production App Engine.
date.timezone = America/New_York
extension=bcmath.so
extension=bz2.so
extension=curl.so
extension=gd.so
extension=gettext.so
extension=mcrypt.so
extension=mysqli.so
extension=mysql.so
extension=openssl.so
extension=pdo_mysql.so
extension=soap.so
extension=zip.so
Happy Apping.
Here's the code that fails - we check if the function exists.
if (!function_exists('bccomp')) {
echo "The PHP runtime requires the \"bccomp\" function, which is not ";
echo "defined.
";
echo "If you built PHP using \"configure\" then please rebuild with:
";
echo ' ./configure --enable-bcmath';
exit(1);
}
I don't know why you'd have the extension enabled but the function not existing. Probably try listing the functions that are available to double check it's there.
php -r 'print_r(get_defined_functions());' | grep -i bccomp