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

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 ?

Related

Unable to start fresh laravel Project. Artisan exists but cannot run artisan serve

Im trying to start a fresh project and am following this guide:
php version: 8.1.9
Composer version: 1.9.0
I'm able to create a project and have tried a few things like installing, updating, updating -- no script, clearing the dump, but it all turns out to me not being able to run php artisan serve
most errors point to the auto load on the fresh load but whenever i've composer dump-autoload and tried and updated and tried this does not solve anything. I've followed this source and cannot find any answers for my solution
Here are my reproduction steps:
visit the laravel install page.
create basic application using composer create-project laravel/laravel example-app
cd into the app
composer update
composer install
when running php artisan serve
error recieved:
PHP Warning:
require(/someapp/vendor/autoload.php): Failed to open stream: No such file or directory in /someapp/artisan on line 18
after running composer dump-autoload
PHP Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in /Documents/someapp/bootstrap/app.php:14```

Why its showing class not found errors?

I just cloned a git repo and ran the necessary commands to install the project.
When I access the login page "http://localhost:80/nova/login" it works. However after enter the correct credentials and submit it shows an error:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class '\App\User' not found
Do you know what can be the issue?
Also running this command:
/var/www # php artisan component:update
It shows a similar error:
Starting Update of All Component files
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'App\Component' not found
After cloning, running through these steps should fix your problem:
run composer install or npm install.
check that the .env file is correct.
run php artisan key:generate
Optional: php artisan migrate
run php artisan serve
Reload composer autloaded classes.
composer dump-autoload

Symfony Doctrine Uncaught PHP Exception ReflectionException

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

Composer update - website stopped working

I updated the Composer using cmd window and got these errors:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Darryldecode\Cart\CartServiceProvider' not found
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output:
The website is not online yet, and I'm running it using xampp.
Now, when i'm trying to access my web site through localhost, I get this error:
FatalErrorException in ProviderRepository.php line 146:
Class 'Darryldecode\Cart\CartServiceProvider' not found.
In the app.php file I have:
Darryldecode\Cart\CartServiceProvider::class,
in the Application Service Providers, and:
'Cart' => Darryldecode\Cart\Facades\CartFacade::class,
in the aliases.
Any ideas on how to get the website back?
Thanks!
Tty this steps
Temporary remove
Darryldecode\Cart\CartServiceProvider::class,
And
'Cart' => Darryldecode\Cart\Facades\CartFacade::class,
Type command
composer update
And then add this class
Because when you update composer he try to find this path before adding in your project, After updating your composer this class added in your folder

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.

Categories