Dokku deployed Silex can't find PdoServiceProvider

核能气质少年 提交于 2019-12-24 12:08:28

问题


I have a project done with Silex, and I was using herrera-io/silex-pdo as the PDO provider, but I faced random crashes with socket errors (I connect to the DB via socket), since that lib is abandoned, I changed to csanquer/pdo-service-provider, and it works just fine on my localhost server, but when I deploy to remote, I get the following error:

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

Here is the code around the line 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,
        ),
    )
);

Thanks in advance for any help, or any clue of what may be going wrong!


回答1:


Turns out the problem was with the use instructions. To fix, simply change:

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

And:

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

Now it works!



来源:https://stackoverflow.com/questions/33684042/dokku-deployed-silex-cant-find-pdoserviceprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!