Symfony fatal error

2020-06-16 09:00发布

Symfony runs correctly but I get this error after I open in browser All my controller is empty Response

FatalThrowableError

Type error: Return value of Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() must be an instance of Doctrine\Common\Annotations\void, none returned

Here is my config file, I use multiple database

# Doctrine Configuration
doctrine:
    dbal:
        default_connection: admin
        connections:
            admin:
                driver: pdo_mysql
                host: '%database_host%'
                port: '%database_port%'
                dbname: '%database_name%'
                user: '%database_user%'
                password: '%database_password%'
                charset: UTF8
            public_branch:
                driver: pdo_mysql
                host: '%database_host1%'
                port: '%database_port1%'
                dbname: '%database_name1%'
                user: '%database_user1%'
                password: '%database_password1%'
                charset: UTF8

    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        default_entity_manager: admin
        entity_managers:
            admin:
                connection: admin
                auto_mapping: true
            public_branch:
                connection: public_branch
                mappings:
                    AdminBundle: ~
                    PublicBranchBundle: ~

What can I do?

标签: symfony
4条回答
看我几分像从前
2楼-- · 2020-06-16 09:09

What the problem fixed for me was, after upgrading to PHP 7.1, also enable PHP 7.1 for apache2 by

$ sudo a2enmod php7.1

I also had to disable PHP 7.0 for some reason:

$ sudo a2dismod php7.0
查看更多
淡お忘
3楼-- · 2020-06-16 09:11

I solved this problem by updating my php from 7.0 to 7.1 , using the following commands:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1-curl php7.1-xml php7.1-zip php7.1-gd php7.1-mysql php7.1-mbstring php7.1
查看更多
等我变得足够好
4楼-- · 2020-06-16 09:24

If some still facing same problem either move to php 7.1 or simply do

composer update

it will automatically downgrade doctrine/annotations from 1.5 to 1.4 which work with php < 7.1

查看更多
Rolldiameter
5楼-- · 2020-06-16 09:29

Unfortunately not every prod server can be upgraded that simply.

Recent Doctrine updates require PHP 7.1..

You can downgrade ORM to 2.5 and necessarily Annotations to 1.4:

    "doctrine/orm": "2.5.6",
    "doctrine/annotations": "1.4.*",
    "doctrine/dbal": "2.5.4",

This way you can still use PHP 7.0.

查看更多
登录 后发表回答