2016-07-19 125 views
0

我正在使用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無法連接到數據庫,因爲我的主機沒有任何連接。所以這是一個正常的行爲。

當我進入虛擬機時,該命令可以正常工作。

所以我可以在這裏停下來,只是從我的虛擬機更新我的依賴關係。

但是,我不想讓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": "[email protected]", 
     "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" 
     } 
    } 
} 

回答

5

由於學說2.5,Dctrine\DBAL\Connection::detectDatabasePlatform()叫上許多命令,並會發出到數據庫中(這裏的問題:https://github.com/doctrine/dbal/issues/990)的呼叫。

的解決方法是在教義配置來設置DB版本:

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

偉大的作品,非常感謝你!對我感到羞恥我沒有自己發現問題:/ – Hammerbot