Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony fatal error

Tags:

symfony

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?

like image 883
A.Seddighi Avatar asked Jul 24 '17 11:07

A.Seddighi


4 Answers

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.

like image 55
webDEVILopers Avatar answered Oct 02 '22 02:10

webDEVILopers


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
like image 45
Ties Avatar answered Oct 02 '22 01:10

Ties


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
like image 32
A.Seddighi Avatar answered Oct 02 '22 03:10

A.Seddighi


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

like image 37
Aref Ben Lazrek Avatar answered Oct 02 '22 01:10

Aref Ben Lazrek