为什么composer更新需要访问数据库



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

这个错误出现在我的开发环境中。我正在使用一个流浪的虚拟机。错误如下:

[DoctrineDBALExceptionConnectionException]                              
  An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused  

      [DoctrineDBALDriverPDOException]        
      SQLSTATE[HY000] [2002] Connection refused  

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

    Script SensioBundleDistributionBundleComposerScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

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

当我ssh到我的虚拟机中时,该命令运行良好。

所以我可以在这里停下来,从我的虚拟机更新我的依赖关系。

然而,我不希望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"
        }
    }
}

由于条令2.5,DctrineDBALConnection::detectDatabasePlatform()在许多命令上被调用,并将对数据库发出调用(此处发出:https://github.com/doctrine/dbal/issues/990)。

解决方法是在条令配置中设置DB版本:

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

相关内容

  • 没有找到相关文章

最新更新