【问题标题】:PDO Fatal error on BluemixBluemix 上的 PDO 致命错误
【发布时间】:2015-08-10 13:53:13
【问题描述】:

我真的坚持在 bluemix 中使 PDO 与 PHP 一起工作。 我无法使用它,每次我收到此错误:

Fatal error: Class 'PDO' not found in ...

然后我在 .bp-config 下添加了 options.json\

{
     "PHP_VERSION": "{PHP_55_LATEST}",
       "WEB_SERVER": "httpd",
     "PHP_EXTENSIONS": [ "bz2", "zlib", "openssl", "fpm", "tokenizer", "curl", "mcrypt", "mbstring", "pdo", "mysqli"]
}

然后我也尝试使用 .bp-config 下的 php.ini\

display_errors = On
display_startup_errors = On
extension=pdo.so
extension=pdo_mysql.so
extension=mysqli.so
extension=mysql.so
extension=mbstring.so

在 phpinfo(); 之后我明白了:

'./configure' '--prefix=/tmp/staged/app/php' '--disable-static' '--enable-shared' '--enable-ftp=shared' '--enable-sockets=shared' '--enable-soap=shared' '--enable-fileinfo=shared' '--enable-bcmath' '--enable-calendar' '--with-kerberos' '--enable-zip=shared' '--with-bz2=shared' '--with-curl=shared' '--enable-dba=shared' '--with-cdb' '--with-gdbm' '--with-mcrypt=shared' '--with-mhash=shared' '--with-mysql=shared' '--with-mysqli=shared' '--enable-pdo=shared' '--with-pdo-sqlite=shared,/usr' '--with-pdo-mysql=shared,mysqlnd' '--with-gd=shared' '--with-jpeg-dir=/usr' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-pdo-pgsql=shared' '--with-pgsql=shared' '--with-pspell=shared' '--with-gettext=shared' '--with-gmp=shared' '--with-imap=shared' '--with-imap-ssl=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-zlib=shared' '--with-xsl=shared' '--with-snmp=shared' '--enable-mbstring=shared' '--enable-mbregex' '--enable-exif=shared' '--with-openssl=shared' '--enable-fpm'

我也试过 composer.json:

{
  "require": {
    "ext-mysqli": "*",
    "ext-pdo": "*",
    "ext-pdo_mysql": "*"
  }
}

但是,在所有这些步骤之后,我仍然得到同样的错误,因为天和天:(:绝望:

【问题讨论】:

  • 您能分享一下您用来将应用程序推送到 Bluemix 的命令吗?
  • 我用过:cf push PROJECTNAME 和清单:[...] disk_quota: 1024M buildpack: php_buildpack path: . domain: mybluemix.net instances: 1 memory: 1G
  • 我只用 composer.json 就成功了。你能分享你的代码吗?

标签: php pdo ibm-cloud


【解决方案1】:

对我来说,作曲家没有工作,但 options.json 是。

.bp-config/ 下的文件 options.json 还应包含您要使用的驱动程序。否则 PDO 本身无法与 DB 通信。

这是我的工作 options.json

{
"PHP_EXTENSIONS": ["bz2", "pdo", "zlib", "curl", "mcrypt", "mbstring", "mysqli", "gd", "zip", "pdo_mysql", "pdo_sqlite" ]
}

通过您提供的 phpinfo(),您可以使用 PDO 与 mysql、sqlite 和 pgsql 进行通信。

要查看是否已加载驱动程序,请运行 phpinfo() 并查找 PDO 部分。应该是这样的:PDO drivers mysql, sqlite

【讨论】:

    【解决方案2】:

    只是尝试复制您的问题,但使用 composer.json 作为您粘贴的配置,它工作正常。 可能您的问题可能与用于解决错误的不同配置之间的冲突有关。 我解决你问题的建议是再次从启动代码开始,确保 MySQL 服务绑定正确,然后用你的代码替换代码,并用你需要的库配置 composer.json。 然后再次推动它,让它完成所有暂存活动(真的很重要!) 如果你设法解决它,请告诉我们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-24
      • 1970-01-01
      • 2012-08-02
      相关资源
      最近更新 更多