为什么作曲家更新需要访问数据库

时间:2016-07-19 14:29:42

标签: symfony composer-php

我正在使用Symfony 2.8并遇到一些问题,启动一个简单的composer update命令。

此错误出现在我的开发环境中。我正在使用流浪汉虚拟机。这是错误:

[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 post-update-cmd event terminated with an exception

当然,当我在主机上启动命令时会发生这种情况。 PHP无法连接到数据库,因为我的主机没有任何连接。所以这是一种正常的行为。

当我进入我的虚拟机时,该命令运行良好。

所以我可以在这里停下来,只是从我的VM更新我的依赖项。

但是,我不希望composer update访问我的数据库,我不明白它为什么需要它。

我应该在哪里查看,或者我可以提供哪些信息来帮助我解决问题?

编辑:这是我的composer.json文件:

{
    "name": "root/blog",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/",
            "SymfonyStandard\\": "app/SymfonyStandard/"
        }
    },
    "require": {
        "php": ">=5.3.9",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~4.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "jms/serializer": "^1.1",
        "gedmo/doctrine-extensions": "dev-master",
        "friendsofsymfony/user-bundle": "~2.0@dev",
        "setasign/fpdf": "^1.8",
        "picqer/php-barcode-generator": "^0.2.0",
        "oneup/flysystem-bundle": "^1.3",
        "itbz/fpdf": "^1.7",
        "milon/barcode": "^5.2"
    },
    "require-dev": {
        "sensio/generator-bundle": "~2.3"
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }
    }
}

1 个答案:

答案 0 :(得分:6)

自Doctrine 2.5以来,Dctrine\DBAL\Connection::detectDatabasePlatform()在许多命令上被调用,并将发出对数据库的调用(此处出现问题:https://github.com/doctrine/dbal/issues/990)。

解决方法是在Doctrine配置中设置数据库版本:

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                server_version: 5.6