2017-02-20 34 views
1

我想驗證我的Symfony 3項目,但我得到作曲家腳本錯誤:SensioLabsInsight無法連接到數據庫

SensioLabsInsight was not able to install your Composer dependencies. If you need to customize files or run commands to make it work, you can edit your SensioLabsInsight project configuration to override the default "pre_composer_script" and/or "post_composer_script" settings.

以下是錯誤:

Loading composer repositories with package information 
Installing dependencies (including require-dev) from lock file 
Nothing to install or update 
Generating optimized autoload files 
> Incenteev\ParameterHandler\ScriptHandler::buildParameters 
Creating the "app/config/parameters.yml" file 
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap 
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache 

    [Doctrine\DBAL\Exception\ConnectionException]        
    An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused 

    [Doctrine\DBAL\Driver\PDOException]   
    SQLSTATE[HY000] [2002] Connection refused 

    [PDOException]        
    SQLSTATE[HY000] [2002] Connection refused 

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception 

    [RuntimeException]                
    An error occurred when executing the "'cache:clear --no-warmup'" command:  

    [Doctrine\DBAL\Exception\ConnectionException]         
    An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused  

    [Doctrine\DBAL\Driver\PDOException]           
    SQLSTATE[HY000] [2002] Connection refused          

    [PDOException]                
    SQLSTATE[HY000] [2002] Connection refused          

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]... 

我不知道爲什麼SensioLabsInsight需要連接到數據庫。

+0

你是否已經找到了解決方案添加服務器版本? –

回答

0

清除緩存後,Symfony會嘗試引導內核。這包括連接到數據庫。

When installing your project's dependencies, the composer install command is executed. In turn, this command executes the cache:clear command, which tries to boot the kernel of your application.

https://insight.sensiolabs.com/help/#how-can-i-connect-to-a-database

我有同樣的問題,並決定用在我的測試環境中的內存pdo_sqlite數據庫(我已經使用其他地方),但你也可以使用MongoDB的,Redis的,或Memcached。

+0

這是一個修復,但不是真正的解決方案。如果您必須在兩種類型的數據庫之間切換,您可能會遇到問題,有時候... –

+0

沒錯,這不是一個完整的解決方案。問題在於,您不應該在SensioLabs Insight等環境中首先連接到數據庫。解決方案是Symfony不需要緩存中的數據庫連接:clear。隨意創建一個拉請求;)。同時,使用此解決方法。 –

1

同樣的問題對我來說,apprently的問題影響DBAL 2.5

所以,你必須在config.yml

doctrine: 
dbal: 
    driver: pdo_mysql 
    host:  "%database_host%" 
    port:  "%database_port%" 
    dbname: "%database_name%" 
    user:  "%database_user%" 
    password: "%database_password%" 
    charset: UTF8 
    server_version: 5.6 

GitHub issue

+0

這沒有幫助,因爲SensioLabsInsight的服務器上沒有數據庫服務器。 –