Symfony Doctrine Uncaught PHP Exception ReflectionException - php

I'm tried to create a new Symfony project with the standard procedure "symfony new my_project_name --full". If I try to access a defined route "/test" I'm getting the following Exception:
REQUES Uncaught PHP Exception ReflectionException: "Class App\Entity\Provider does not exist" at C:\xampp\htdocs\Sauber\template\vendor\doctrine\persistence\lib\Doctrine\Persistence\Mapping\Driver\AnnotationDriver.php line 179
The Class App\Entity\Provider is an entity from another project and isn't defined anywhere in the new project and I just don't unserstand where this is coming from.

I had the same problem and solved it warming the cache for the environment as in this link:
Symfony - How to solve the doctrine issue of the missing annotations?.
Basically:
php bin/console cache:clear
php bin/console cache:warmup

As carlam.14 mentioned, running cache:clear may solve it for you. For me running it through the symfony CLI tool was what finally fixed this for me:
symfony console cache:clear
symfony console cache:warmup

Related

Symfony | Uncaught PHP Exception ReflectionException: "Class "App\Entity\Site" does not exist"

i have a git symfony project i want to work localy , after clone and composer install, i have this error : Uncaught PHP Exception ReflectionException: "Class "App\Entity\Site" does not exist" but this class is from an other project.
As mentioned in other topics as this one or this one, i cleared cache with php bin/console cache:clear php bin/console cache:warmup symfony console cache:clear ...
I tried to access to the website with symfony server:start and from xampp, same result.
I also tried to launch php server with php -S localhost:8000 -t public/.
Same result, it looks like it remains some caches somewhere i dont know ?

Symfony framework problem with creating controller

I just started to learn Symfony framework and I got stuck on very begging.
I created with composer with following commands:
composer require symfony/maker-bundle --dev
composer require annotations
php bin/console make:controller ToDoListController.php
Code looks good, but when I try to open this controller I am getting an error message:
Uncaught Error: Class 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController' not found in C:\xampp\htdocs\symfony44\src\Controller\ToDoListController.php:9 Stack trace: #0 {main} thrown in C:\xampp\htdocs\symfony44\src\Controller\ToDoListController.php on line 9.
I am using xampp as a local server, symfony 4.4
Has anyone encountered with this problem?
Please install symfony using the symfony app. Download the app for windows from https://symfony.com/download.
Open the windows command prompt.
type the following commands
symfony new project-name --full
cd project-name
symfony serve
symfony serve starts your development server. Use apache when your app is deployed. With the symfony app you can use https. This method of symfony installation is easy and it is good for those new to symfony. With the --full option maker bundle and all other important bundles are installed for you. You can just start creating controllers

Getting Fatal Error when trying to run the Doctrine CLI on mac

I've been following the Doctrine getting-started docs and am immediately running into a problem with Doctrine's CLI.
If I try to run
vendor/bin/doctrine orm:schema-tool:create
or
vendor/bin/doctrine orm:schema-tool:drop
or even
php /vendor/bin/doctrine
I get this error in my terminal...
PHP Fatal error: Uncaught Error: Class
'Doctrine\Common\Annotations\AnnotationRegistry' not found in
/Users/admin/.bitnami/stackman/machines/xampp/volumes/root/htdocs/doctrine2-tutorial/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php:152
Any help would be much appreciated.
If you are trying to create a database use the following:
bin/console doctrine:database:create
If you want to create your database with doctrine, you may update your composer version with dependency, after you delete de composer.lock before taping this following commande : composer install
Actually, the latest stable version of doctrine is 2.11.* . To resolve this problem, i juste upadate my doctrine :
{
{
"require": {
"doctrine/orm": "^2.11.0",
},
}
->vendor/bin/doctrine orm:schema-tool:create

Symfony 2 : Error when cache clear

I have an error when i execute this command :
php app/console cache:clear --env=prod && php app/console cache:clear --env=dev && php app/console assets:install --symlink && php app/console assetic:dump
The error is :
[Symfony\Component\Debug\Exception\ContextErrorException] Catchable
Fatal Error: Argument 1 passed to
Sonata\AdminBundle\Security\Handler\RoleSecurityHandler::__construct()
must implement interface
Symfony\Component\Security\Core\SecurityContextInter face, null
given, called in
/opt/preprod/app/cache/pro_/ap_ProdProjectContainer.php on line 1923
and defined
Can you help i dont really know how to fix this
EDIT
I tried to backup
composer.lock
and
vendor
directory (and then delete them). Then i deleted mannually the cache.
Then i made a composer install but the error is back when i made the composer install.
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
[Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 1 passed to Sonata\AdminBundle\Security\Handler\RoleSecurityHandler::__construct() must implement interface Symfony\Component\Security\Core\SecurityContextInterface, null given, called in /opt/preprod/app/cache/dev/appDevDebugProjectContainer.php on line 4984 and defined
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
php app/check.php give me everything is ok
So i dont find the way to solve this
What version of Symfony are you using? I would guess 2.8 or 3.0 since it looks like the version of SonataAdminBundle is not compatible with your Symfony version.

PHPUnit with Symfony Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle' not found

I'm trying to testing my app made with Symfony. I wrote a test and when I launch it, i get the following error:
Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle'
not found in /.../app/AppKernel.php on line 17
I had the same error with Symfony's MonologBundle, AsseticBundle and SwiftmailerBundle: then I've manually added these bundles into my app, so pheraps I have fixed those errors, but with Doctrine I've not found any solutions yet.
It looks like maybe you did not install the Doctrine bundle.
Try to go to the root of your project where the composer.phar is located through a console, and try to run it like this:
php composer.phar
It will install all dependencies of Symfony2,and hopefully everything is going to work :)

Categories