为什么作曲家更新需要访问数据库 [英] Why does a composer update need access to the database

查看:64
本文介绍了为什么作曲家更新需要访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working with Symfony 2.8 and running into some issues launching a simple composer update command.

此错误来自我的开发环境。我正在使用无所事事的虚拟机。错误如下:

This error comes on my development environment. I am using a vagrant virtual machine. Here is the error:

[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无法连接到数据库,因为我的主机没有任何主机。因此,这是正常行为。

Of course, this is happening when I launch the command on my host machine. PHP cannot connect to the database because my host machine doesn't have any. So this is a normal behaviour.

当我SSH到VM中时,该命令运行良好。

The command works well when I ssh into my VM.

所以我可以在这里停止,然后从我的VM更新我的依赖项。

So I could stop here and just update my dependencies from my VM.

但是,我不希望 composer更新访问我的数据库,而且我不知道为什么它会需要它。

However, I don't want a composer update to access my database, and I don't see why it would need it.

我应该在哪里查看或我可以给您提供什么信息来帮助我解决问题?

Where should I look or what information could I give you to help me solve my problem?

编辑:这是我的 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"
        }
    }
}


推荐答案

自Doctrine 2.5起, Dctrine\DBAL\Connection :: detectDatabasePlatform()会在许多命令上调用,并且会发出调用数据库(在此处发出: https://github.com/doctrine/dbal/issues/990 )。

Since Doctrine 2.5, Dctrine\DBAL\Connection::detectDatabasePlatform() is called on many commands and will issue a call to the database (issue here: https://github.com/doctrine/dbal/issues/990).

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

The workaround is to set DB version in Doctrine configuration:

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

这篇关于为什么作曲家更新需要访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆