4

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

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.

The command works well when I ssh into my VM.

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

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?

EDIT: Here is my composer.json file:

{
    "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"
        }
    }
}
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Hammerbot
  • 15,696
  • 9
  • 61
  • 103

1 Answers1

8

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).

The workaround is to set DB version in Doctrine configuration:

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                server_version: 5.6
romaricdrigon
  • 1,497
  • 12
  • 16