I cannot run symfony local server by command: php bin/console server:run. I get error: [Symfony\Component\Console\Exception\LogicException] An option named "connection" already exists.
Dependencies in composer.json:
"require": {
"php": "^7.0, <7.4",
"composer/package-versions-deprecated": "^1.11",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"doctrine/data-fixtures": "^1.3",
"doctrine/doctrine-fixtures-bundle": "^2.3",
"liip/functional-test-bundle": "^1.8",
"phpunit/phpunit": "^6.3",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
parameters.yml:
# This file is auto-generated during the composer install
parameters:
database_host: 127.0.0.1
database_port: 3306
database_name: tests
database_user: root
database_password: password
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt
I think these parameters in parameters.yml used to work earlier. I use mysql and also sqlite for tests.
I faced the same issue in a Symfony v4.2 project, without changing anything in my code base.
As already found in this issue https://github.com/doctrine/dbal/issues/4565
it appears in certain versions of the
doctrine/doctrine-bundlepackage (in my case v1.11). TheRunSqlDoctrineCommand.phpfrom vendor adds the second option which causes the error.If you can update your
doctrine/doctrine-bundlepackage, you might be fine. In my case, an update or fix by package was not possible.What can we do in that case?
What comes next is more a hack, than a real good solution, so use it at your own risk!
As statet in the commit from official repository: https://github.com/doctrine/DoctrineBundle/commit/86d2469d6be06d55ad7b9e2f076f6942476f2e87 (thanks to the guys in issue above)
I made a copy of the new
RunSqlDoctrineCommand.phpfrom that commit and save it in my project asdist/RunSqlDoctrineCommand.php.In
composer.jsonchange thescriptssections as follows:This will just copy and override the original file in vendor directory on every
composer install/update. This will only work on a unix/linux system, btw.As said: Not the best solution, but it keeps your project in shape.