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-bundle package (in my case v1.11). The RunSqlDoctrineCommand.php from vendor adds the second option which causes the error.
If you can update your doctrine/doctrine-bundle package, 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.php from that commit and save it in my project as dist/RunSqlDoctrineCommand.php.
In composer.json change the scripts sections as follows:
{
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd"
},
"doctrine-bugfix": [
"cp -f dist/RunSqlDoctrineCommand.php vendor/doctrine/doctrine-bundle/Command/Proxy/RunSqlDoctrineCommand.php"
],
"post-install-cmd": [
"#auto-scripts",
"#doctrine-bugfix"
],
"post-update-cmd": [
"#auto-scripts",
"#doctrine-bugfix"
]
}
}
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.
In this answer is there is a good explanation
in my case
composer update doctrine/doctrine-bundle
Inside (symfony project) vendor/doctrine/doctrine-bundle/Command/Proxy/RunSqlDoctrineCommand.php change configure function like below:
protected function configure()
{
parent::configure();
$this
->setName('doctrine:query:sql')
//->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The
connection to use for this command')
->setHelp(<<<EOT
The <info>%command.name%</info> command executes the given SQL query and
outputs the results:
<info>php %command.full_name% "SELECT * FROM users"</info>
EOT
);
if ($this->getDefinition()->hasOption('connection')) {
return;
}
$this->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The
connection to use for this command');
}
Related
After a composer update to fix some vulnerabilities on package used by my application, I handle an error:
The service "sensio_framework_extra.controller.listener" has a dependency on a non-existent service "annotation_reader"
As suggested in this answer, I tried to add the doctrine/annotations package, but it doesn't solved my issue (package seems to be already installed).
λ composer require doctrine/annotations
Using version ^1.8 for doctrine/annotations
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Nothing to install or update
Here is the packages used by my composer.json:
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-json": "*",
"doctrine/doctrine-fixtures-bundle": "^3.1",
"ekyna/payum-monetico-bundle": "^1.5",
"gedmo/doctrine-extensions": "^2.4",
"knplabs/knp-paginator-bundle": "^3.0",
"payum/offline": "^1.5",
"payum/paypal-express-checkout-nvp": "^1.5",
"payum/payum-bundle": "^2.3",
"php-http/guzzle6-adapter": "^2.0",
"sensio/framework-extra-bundle": "^5.1",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/asset": "4.2.*",
"symfony/console": "4.2.*",
"symfony/dotenv": "4.2.*",
"symfony/expression-language": "4.2.*",
"symfony/flex": "^1.1",
"symfony/form": "4.2.*",
"symfony/framework-bundle": "4.2.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "1.*",
"symfony/process": "4.2.*",
"symfony/security-bundle": "4.2.*",
"symfony/serializer-pack": "1.*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/templating": "4.2.*",
"symfony/translation": "4.2.*",
"symfony/twig-bundle": "4.2.*",
"symfony/validator": "4.2.*",
"symfony/web-link": "4.2.*",
"symfony/webpack-encore-bundle": "^1.4",
"symfony/yaml": "4.2.*",
"twig/extensions": "^1.5",
"vich/uploader-bundle": "^1.8"
},
"require-dev": {
"codeception/codeception": "^2.5",
"codeception/c3": "2.*",
"friendsofphp/php-cs-fixer": "^2.14",
"php-coveralls/php-coveralls": "^2.1",
"phpmd/phpmd": "2.*",
"squizlabs/php_codesniffer": "*",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.11",
"symfony/profiler-pack": "*",
"symfony/test-pack": "^1.0",
"symfony/web-server-bundle": "4.2.*"
}
Edit :
I'm using all the framework, I've manually dropped cache to be sure there is no problem. I rebooted my dev computer too. Finally, I went around the problem by deploying my github project in another directory and application works fine. I don't close this question because I want to find the problem if it occurs in production.
since doctrine (or doctrine/annotations) itself does not register services (why would it), I looked up the doctrine bundles and the doctrine/doctrine-bundle provides the annotation_reader service: https://github.com/doctrine/DoctrineBundle/blob/af8ac792c9b970ff2bc25b49ab9b31afd9e03dbf/Resources/config/orm.xml#L82
I ran into a very similar error (The service "doctrine.orm.default_annotation_metadata_driver" has a dependency on a non-existent service "annotation_reader".) while trying to create a new setup. I have some instructions documented and had tried to composer install ormfixtures (--dev) before doctrine. Once I did that in the right order, everything was working as expected.
My specific example is from Twilio's instructions, which have these commands in this order:
composer req --dev maker ormfixtures fakerphp/faker
composer req doctrine twig
It worked when I reversed them to be in this order:
composer req doctrine twig
composer req --dev maker ormfixtures fakerphp/faker
I Had the same issue after a composer update from Symfony 4.4.
It was because I have replace de "Doctrine\Common" with "Doctrine" from all the using instead of "Doctrine\Common\Persistence" with "Doctrine\Persistence".
In other term: no matters why you have this error, it come from a broken namespace in your code.
This is the official link of the SensioFrameworkExtraBundle: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
I've been trying to install the cache/cache-bundle recipe into my symfony4 flex-configured project, but to no avail. I execute:
composer require cache/cache-bundle
And this is what I got on the shell:
Installing the cache-bundle generates a cache.yml file under config/packages/cache.yml, and its default content is:
cache:
session:
enabled: "%env(bool:SESSION_CACHE_ENABLED)%"
service_id: "cache.provider.default"
use_tagging: true
ttl: 7200
router:
enabled: "%env(bool:ROUTER_CACHE_ENABLED)%"
service_id: "cache.provider.default"
ttl: 86400
logging:
enabled: "%env(bool:APP_DEBUG)%"
logger: "logger"
level: "info"
The problematic line is the first "enabled" one. For some reason, Symfony or composer doesn't like that %env(bool:SESSION_CACHE_ENABLED)% and returns that error message:
Invalid type for path "cache.session.enabled". Expected boolean, but
got string.
SESSION_CACHE_ENABLED is a value introduced in the .env file of the project by composer in a block like this.
###> cache/cache-bundle ###
SESSION_CACHE_ENABLED=true
ROUTER_CACHE_ENABLED=false
###< cache/cache-bundle ###
Then, the question is if someone else has "suffered" this problem and found a fix or workaround to make this config work. My objective is to use this dependency in my mock project to cache arrays in memory to use them as a fake DB system.
I thought to open an issue about this, but since I'm not sure if this is a Simfony issue or just a problem in the recipe I preferred to ask here first.
And for the sake of completion, here's the list of current dependencies already in my project.
"require": {
"php": "^7.1.3",
"easycorp/easy-log-handler": "^1.0",
"friendsofsymfony/rest-bundle": "^2.3",
"hermes/bridge/common": "dev-master",
"hermes/common": "dev-master",
"jms/serializer": "^1.10",
"jms/serializer-bundle": "^2.3",
"ramsey/uuid": "^3.7",
"sensio/framework-extra-bundle": "^5.1",
"symfony/cache": "^4.0",
"symfony/console": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/http-foundation": "^4.0",
"symfony/monolog-bundle": "^3.1",
"symfony/stopwatch": "^4.0",
"symfony/web-server-bundle": "^4.0",
"symfony/yaml": "^4.0"
},
"require-dev": {
"symfony/flex": "^1.0",
"symfony/dotenv": "^4.0"
}
I've seen questions about issues regarding booleans in dotenv files, but nothing conclusive for this question, I'm afraid.
Have you tried to get rid off the quotes around "%env(bool:SESSION_CACHE_ENABLED)%"?
When I use this command in cmd
php composer.phar update friendsofsymfony/user-bundle
I get this message
Please provide a version constraint for the
friendsofsymfony/user-bundle requirement: 2.0.*#dev composer.json has
been updated Loading composer repositories with package information
Updating dependencies (including require-dev) Your requirements could
not be resolved to an installable set of packages.
Problem 1
- The requested package friendsofsymfony/user-bundle could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting see
https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion
for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for
further common problems.
Installation failed, reverting composer.json to its original content.
I've already added "minimum-stability": "dev", in my composer.json
It's the first time that I head this problem I installed fosuserbundle manytimes and it worked before.
I just Advice you just use this to configure all the sonata admin + fos user bundle without any dependencies or version conflicts
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.5.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"sonata-project/admin-bundle": "~2.3#dev",
"sonata-project/doctrine-orm-admin-bundle": "~2.3#dev",
"sonata-project/core-bundle": "~2.2#dev",
"sonata-project/user-bundle": "2.2.x-dev",
"friendsofsymfony/user-bundle": "~1.3#dev",
"sonata-project/easy-extends-bundle": "~2.1#dev",
"sonata-project/intl-bundle": "2.2.x-dev",
"knplabs/knp-paginator-bundle": "dev-master",
"knplabs/knp-time-bundle": "dev-master",
"knplabs/knp-menu-bundle": "1.1.*",
"jms/serializer-bundle": "0.13.*#dev"
},
So I fixed, it should be:
"friendsofsymfony/user-bundle": "~2.0#dev"
not
"friendsofsymfony/user-bundle ": "~2.0#dev"
I am trying to set up Symfony with the SonataUserBundle. User registration and login works fine. When I try to call up the /profile view, however I get the following error:
Attempted to call method "setCurrentUri" on class "Knp\Menu\MenuItem" in F:\<my project path>\vendor\sonata-project\user-bundle\Block\ProfileMenuBlockService.php line 91. Did you mean to call: "setCurrent"?
The last notice in the "event list" before the error is
INFO - [cms::renderBlock] block.id=53, block.type=sonata.user.block.menu
Has anyone encountered this error before and can provide information on how to resolve it?
TIA
Matt
What versions of KnpMenu and SonataBlockBundle are you using? Please check your composer.json to be sure.
The setCurrentUri method has been deprecated as of KnpMenu v. 2.0, and the composer.json of SonataBlockBundle does not require KnpMenu anywhere but in dev install. So, this leads to a possibility that you could have required a fresher version of knplabs/knp-menu-bundle that is not yet supported by Sonata bundle.
Try requiring knplabs/knp-menu-bundle in 1.1.x:
{
...
"require": {
"knplabs/knp-menu-bundle": "~1.1"
},
...
}
I encountered the same problem, but downgrade to Knpmenu version 1 is not possible for our project. Because of some code update the June 16th, it is now possible to use Sonata User Bundle and Knp Menu Version 2.
Please, have a look on my composer.json :
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/migrations": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master",
"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",
"friendsofsymfony/user-bundle": "~1.3",
"friendsofsymfony/message-bundle": "^1.2",
"sonata-project/admin-bundle": "^2.3",
"sonata-project/doctrine-orm-admin-bundle": "^2.3",
"sonata-project/easy-extends-bundle": "^2.1",
"sonata-project/user-bundle": "dev-master",
"sonata-project/datagrid-bundle": "dev-master",
"sonata-project/block-bundle": "~2.2,>=2.2.7,<2.3",
"sonata-project/exporter": "^1.4",
"sonata-project/intl-bundle": "^2.2",
"knplabs/knp-menu-bundle": "~2.0",
"knplabs/knp-menu": "~2.0"
},
As you can see, sonata-project/user-bundle is under dev-master version and I had to add sonata-project/datagrid-bundle in dev-master
Hope to help developpers who want want to preserve KnpMenu V2 !
I had same issue, This is my solution that you can preserve KnpMenu V2.
-You change setCurrentUri to setCurrent (because KNP changed code) in C:\path\vendor\sonata-project\user-bundle\Block\ProfileMenuBlockService.php
-You can have this problem, Method "currentAncestor" for object "Knp\Menu\MenuItem" does not exist in Sonata
And this works for me.
I'm trying to install Symfony 2. I get the same issue of I download the archive without vendors and if I try to install via curl.
Running OSX/MAMP setup.
➜ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing symfony/icu (v1.0.0)
Downloading: connection...^C
➜ composer install -vvv
Downloading composer.json
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /Users/alexlongshaw/.composer/cache/repo/https---packagist.org/packages.json into cache
Downloading https://packagist.org/p/provider-active$fa1339d67d333d9449a21f7a2c80888f2c7a02dbb4d3e6b11a9dd5855df3f537.json
....
Downloading http://packagist.org/p/symfony/class-loader$962a39a1da8588e7f97e22517580a460d5349699d5ccb967167c2a1e9802ce50.json
Reading /Users/alexlongshaw/.composer/cache/repo/https---packagist.org/provider-symfony$class-loader.json from cache
zlib_decode(): data error
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Downloading http://packagist.org/p/symfony/config$eec66e956c41b0728a7fc4f40b95a116bc469f8583c2602b14af3d00f36711fc.json
Writing /Users/alexlongshaw/.composer/cache/repo/https---packagist.org/provider-symfony$config.json into cache
Reading /Users/alexlongshaw/.composer/cache/repo/https---packagist.org/provider-phpoption$phpoption.json from cache
- Installing symfony/icu (v1.0.0)
Downloading https://api.github.com/repos/symfony/Icu/zipball/v1.0.0
Downloading: connection...
As you can see below, if I do composer update I get a similar problem.
➜ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
zlib_decode(): data error
http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
- Installing symfony/icu (v1.0.0)
Downloading: connection...
Any suggestions on how to get past this? It works fine for me on an Ubuntu VM so I presume it is something to do with the setup.
Composer.json
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "stable",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
zlib extension enabled?
check your phpinfo if zlib ( which provides zlib_decode ) is enabled or run
php -m
if your php cli uses a different php.ini
cache problem?
[...] package information was loaded from the local cache and may be out of date
Delete composer's cache folder being...
/Users/alexlongshaw/.composer/cache/
... in your case to prevent updating from cache only and see if a general connection exists.
proxy?
make sure you don't have a proxy set via environment-variables
https_proxy
http_proxy
HTTPS_PROXY
HTTP_PROXY
common problems
composer has built-in capabability of identifying some common problems
composer diagnose
This turned out to be network related. Didn't work on either connection (Broadband or 3G) at home but at work there were no problems