Composer php SensioLabsInsight可以';无法连接到数据库

Composer php SensioLabsInsight可以';无法连接到数据库,composer-php,symfony,Composer Php,Symfony,我正在尝试验证我的Symfony 3项目,但我在编写脚本时出错: SensioLabsInsight无法安装您的Composer依赖项。如果需要自定义文件或运行命令以使其正常工作,可以编辑SensioLabsInsight项目配置以覆盖默认的“编写前脚本”和/或“编写后脚本”设置 以下是错误: Loading composer repositories with package information Installing dependencies (including require-dev)

我正在尝试验证我的Symfony 3项目,但我在编写脚本时出错:

SensioLabsInsight无法安装您的Composer依赖项。如果需要自定义文件或运行命令以使其正常工作,可以编辑SensioLabsInsight项目配置以覆盖默认的“编写前脚本”和/或“编写后脚本”设置

以下是错误:

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>]...
使用包信息加载composer存储库
从锁文件安装依赖项(包括需要开发)
没有要安装或更新的内容
生成优化的自动加载文件
>IncenteV\ParameterHandler\ScriptHandler::buildParameters
创建“app/config/parameters.yml”文件
>Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
>Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
[条令\DBAL\Exception\ConnectionException]
驱动程序中发生异常:SQLSTATE[HY000][2002]连接被拒绝
[条令\DBAL\Driver\PDOException]
SQLSTATE[HY000][2002]连接被拒绝
[例外情况]
SQLSTATE[HY000][2002]连接被拒绝
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache处理symfony脚本事件时异常终止
[运行时异常]
执行“'cache:clear--no warmup'”命令时出错:
[条令\DBAL\Exception\ConnectionException]
驱动程序中发生异常:SQLSTATE[HY000][2002]连接被拒绝
[条令\DBAL\Driver\PDOException]
SQLSTATE[HY000][2002]连接被拒绝
[例外情况]
SQLSTATE[HY000][2002]连接被拒绝
安装[--首选源][--首选区][--干运行][--开发][--无开发][--无自定义安装程序][--无自动加载程序][--无脚本][--无进度][--无建议]-[v | vv | vvv |--verbose][o |--优化自动加载程序][--类映射权威][--apcu自动加载程序][--忽略平台需求][--[--]。。。

我不知道为什么SensioLabsInsight需要连接到数据库。

清除缓存后,Symfony尝试引导内核。这包括连接到数据库

安装项目的依赖项时,composer会安装 命令被执行。该命令依次执行cache:clear 命令,该命令尝试引导应用程序的内核


我也遇到了同样的问题,决定在我的测试环境中使用内存中的
pdo_sqlite
数据库(我已经在其他地方使用过),但您也可以使用MongoDB、Redis或Memcached。

我也遇到了同样的问题,显然这个问题影响到了DBAL2.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

这是一个解决方案,但不是真正的解决方案。如果必须在两种类型的数据库之间切换,有时可能会出现问题……没错,这不是一个完整的解决方案。问题是,在SensioLabs Insight这样的环境中,首先不应该连接到数据库。解决方案是Symfony,不需要在cache:clear上建立数据库连接。可以随意创建拉取请求;)。同时,使用此解决方法。这没有帮助,因为SensioLabsInsight的服务器上没有数据库服务器。您已经找到解决方案了吗?