Symfony 3.4 getDoctrine() results in error

160
May 01, 2018, at 05:08 AM

I have seen some posts about this topic but not the answer I am looking for. When I call $this->getDoctrine(); from a method say public function returnObjectAction(){} and the Class implements use Symfony\Bundle\FrameworkBundle\Controller\Controller it results in container == 0. I also tried $this->getDoctrine()->getManager(); and this also ends with the error "Internal Server Error. The server encountered an internal error or misconfiguration and was unable to complete your request." Ref: https://symfony.com/doc/3.4/doctrine.html#fetching-objects-from-the-database

Thanks.

enter image description here

Answer 1

Check your controller extends Controller ( in addition to the use ), this way:

class YourController extends Controller {}

And that you have doctrine/orm and doctrine/doctrine-bundle in the require part of your composer.json

Add them if it's missing.

Run a composer install

READ ALSO
SQL innerjoin convert integer to text

SQL innerjoin convert integer to text

I have an SQL database directorydb that holds two tables: departments and persons

108
display username AFTER user has logged in PHP MySQL

display username AFTER user has logged in PHP MySQL

I've built a simple user register and login system, using PHP and bootstrapI am a static designer so PHP is very new to me and I'm struggling with the syntax and logic so far, but I am enjoying it

131
How to replace JSON key's value in mysql

How to replace JSON key's value in mysql

I have a mysql JSON column like:

144
EF: Incorrect usage of spatial/fulltext/hash index and explicit index order

EF: Incorrect usage of spatial/fulltext/hash index and explicit index order

I'm using Entity framework with my WEB Api projectI use code first migration

1671