Reputation: 114
I'm stuck with a problem which looks quite small but I can't manage to solve it. It's probably very silly, but I cannot find any solution.
I'm developing a Symfony 3 application with PHP 7.1 on my PC. Everything is working well. I tried to upload it on my host server which is using PHP 7.0.
When I start the website, I get this error message :
Fatal error: Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() must be an instance of Doctrine\Common\Annotations\void, none returned in /home/clients/fb3f5a508aeeb6d39e6d7e1e47bda9ac/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117 Stack trace: #0 /home/clients/fb3f5a508aeeb6d39e6d7e1e47bda9ac/app/autoload.php(9): Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(Array) #1 /home/clients/fb3f5a508aeeb6d39e6d7e1e47bda9ac/web/app.php(6): require('/home/clients/f...') #2 {main} thrown in /home/clients/fb3f5a508aeeb6d39e6d7e1e47bda9ac/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 117
I found those to links which seem to be very helpful: - Symfony fatal error - http://www.doctrine-project.org/2017/07/25/php-7.1-requirement-and-composer.html
But, I couldn't solve the issue. I cannot find which version I need to be compatible with PHP 7.0...
In my composer json config file, I have:
"platform": {
"php": "7.0"
},
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"misd/phone-number-bundle": "^1.2",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/monolog-bundle": "^3.0.2",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0"
},
What am I doing wrong? Any ideas?
Thanks!
Upvotes: 0
Views: 8278
Reputation: 5086
I found the problem was solved when I ran:
composer update --with-dependencies
This pulled in the missing doctrine/annotations
dependency that was missed when I ran just composer update
...
Package operations: 1 install, 0 updates, 0 removals
- Installing doctrine/annotations (1.7.x-dev 232c5da): Cloning 232c5da390 from cache
Writing lock file
Generating autoload files
...
Upvotes: 2
Reputation: 1890
The right way is to check which php you have:
php --version
then tell that composer to automatically blacklist not matching versions
composer config platform.php 7.0.17
then see if composer can downgrade that package (and only that package, we don't want unrelated updates; dry-run = only see, don't do)
composer update doctrine/common --with-dependencies --dry-run
and in my case composer told me that we also need to downgrade another package, so i finally did
composer update doctrine/common symfony/dom-crawler --with-dependencies
which worked out.
Upvotes: 3
Reputation: 114
Problem solved! :-) I downloaded the version 1.2.7 of annotations from the website of Doctrine and it worked. http://www.doctrine-project.org/projects/annotations.html
The weird thing is that on their website, they say that the last version is 1.2.7 but I could download the version 1.4.0 with Composer...
Upvotes: 0
Reputation: 5881
Your platform
setting is ignored as you did not wrap it inside the config
node. The following config would be working:
{
"config": {
"platform": {
"php": "7.0"
},
},
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"misd/phone-number-bundle": "^1.2",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/monolog-bundle": "^3.0.2",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0"
}
}
Upvotes: 5
Reputation: 335
If you use platform as "php": "7.0" then you will try by this
"require": {
"php" : ">=7.0.21",
"symfony/symfony" : "3.3.4",
"doctrine/orm" : "2.5.10",
"doctrine/doctrine-bundle" : "1.6.8",
"doctrine/doctrine-cache-bundle" : "1.3.0",
...
If you strictly define version for all it will easy to find version specific bug.
this is working good for me.
Upvotes: 4