在Bluemix中激活PHP扩展 [英] Activating PHP extensions in Bluemix

查看:69
本文介绍了在Bluemix中激活PHP扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个纯粹的Bluemix问题!

This is a purely Bluemix question!

我已经在本地主机上顺利运行了代码,但是当我将其迁移到Bluemix时,我的数据库连接失败了.检查日志后,发现问题为调用未定义的函数mysqli_init()" HTTP响应500.我发现已禁用扩展名以使其更小,并找到了一些有关它的详细信息:

I've got code running smoothly on a localhost but when I migrated it to Bluemix my DB connection failed me. Checking the logs I found the issue "Call to undefined function mysqli_init()" HTTP response 500. I have found out that extension have been disabled to make it smaller and have found some details about it: Buildpack options.

不幸的是,我尝试过但失败了.也许我误解了解决方案.

Unfortunately I have tried that and failed. Maybe I have misunderstood the solution.

任何帮助将不胜感激.

Any Help would be greatly appreciated.

bgconfig-> bp-config解决了未定义的函数错误"

bgconfig --> bp-config solved the "undefined function error"

似乎添加了一些扩展名,但不是全部. 致命错误:在第15行的/home/vcap/app/htdocs/db_config.php中找不到类'PDO'"

It seems that some extension have been added but not all. "Fatal error:Class 'PDO' not found in /home/vcap/app/htdocs/db_config.php on line 15"

但是我在options.json中添加了PDO扩展名.

I have however added the PDO extension in options.json.

我尝试添加php.ini覆盖

I tried adding a php.ini overwrite

但仍然出现相同的错误...

But still get the same error...

有关信息:db_config.php上的第15行很简单:

For info: line 15 on db_config.php is simply:

$db = new PDO('mysql:host=us-cdbr-iron-east-02.cleardb.net;dbname=ad_dae231843a962ca', $username, $password);}

在try&之内当然.

within try & catch of course.

有线索吗?

推荐答案

您发布的options.json文件是正确的.但是,它位于错误的目录中,它应该位于名为.bp-config/的文件夹中.重命名该文件夹,然后将您的应用重新推回到Bluemix.

The options.json file is correct that you have posted. However it is in the wrong directory, it should be in a folder called .bp-config/. Renamed the folder and repush your app back to Bluemix.

还尝试将pdo_mysql添加到.bp-config/options.json.

我刚刚使用PDO驱动程序针对数据库测试了一些代码,并且运行良好.我的.bp-config/options.json文件在下面.

I just tested some code with the PDO driver against a DB and it worked fine. My .bp-config/options.json file is below.

{
    "PHP_EXTENSIONS": ["pdo", "mysqli", "pdo_mysql", "mysql"]
}

我将使用MySQL桌面客户端再次检查您对数据库的访问.您的连接信息似乎有问题.

I would double check your access to the database with a MySQL desktop client. It looks like an issue with your connection information.

我有一个示例应用,用于测试您与PDO的连接信息.

I have an example app for testing your connection information with PDO.

这篇关于在Bluemix中激活PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆