Dokku部署Silex无法找到PdoServiceProvider

时间:2015-11-13 00:36:01

标签: php pdo composer-php silex dokku

我有一个完成Silex的项目,我使用herrera-io/silex-pdo作为PDO提供程序,但我遇到了套接字错误的随机崩溃(我通过套接字连接到数据库),因为该lib被放弃了,我更改为csanquer/pdo-service-provider,它在我的localhost服务器上工作正常,但是当我部署到远程时,我收到以下错误:

PHP Fatal error: Class 'Csanquer\Silex\PdoServiceProvider\Provider\PdoServiceProvider' not found in /app/web/index.php on line 52

以下是第52行的代码:

use Csanquer\Silex\PdoServiceProvider\Provider\PdoServiceProvider;

$app->register(
// you can customize services and options prefix with the provider first argument (default = 'pdo')
    new PdoServiceProvider('pdo'), // Line 52
    array(
        'pdo.server'   => array(
            // PDO driver to use among : mysql, pgsql , oracle, mssql, sqlite, dblib
            'driver'   => 'mysql',
            'host'     => 'unix_socket=/app/mysqld.sock',
            'dbname'   => 'db_beta',
            'port'     => 3306,
            'user'     => 'user',
            'password' => 'pass',
        ),
        // optional PDO attributes used in PDO constructor 4th argument driver_options
        // some PDO attributes can be used only as PDO driver_options
        // see http://www.php.net/manual/fr/pdo.construct.php
        'pdo.options' => array(
            \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
        ),
        // optional PDO attributes set with PDO::setAttribute
        // see http://www.php.net/manual/fr/pdo.setattribute.php
        'pdo.attributes' => array(
            \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
        ),
    )
);

提前感谢任何帮助,或任何可能出错的线索!

1 个答案:

答案 0 :(得分:0)

原来问题在于使用说明。要修复,只需更改:

use Csanquer\Silex\PdoServiceProvider\Provider\PdoServiceProvider; 至: use Csanquer\Silex\PdoServiceProvider\Provider\PDOServiceProvider;

new PdoServiceProvider('pdo')致:new PDOServiceProvider('pdo')

现在有效!