Symfony 4 production WebProfiler route - symfony

I try to change a Symfony 4.4 in production mode but after executing this command line from the documentation : APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear
I get this error :
Bundle "WebProfilerBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your App\Kernel.php file? in #WebProfilerBundle/Resources/config/routing/wdt.xml (which is being imported from "/home/admin/mercenaries/config/routes/dev/web_profiler.yaml")
The env is correct because the bundle is not loaded.
But how do I do for cancel this routes/dev repository to load ?

Related

Symfony 6, Can't create a controller

I've installed Php 8 and I try to start coding with Symfony but I can't even create a controller.
I've created my project with:
create-project symfony/website-skeleton covid
The project was created with the version 6.1.99.
Then, in VScode, I used
symfony console make:controller Home
and it give me an error:
Parse error: syntax error, unexpected '?' in D:\Bureau\dev\covid\vendor\autoload_runtime.php on line 15
I don't understand why it's happening. Any idea ?
Edit:
It works fine if I use
php bin/console make:controller home
It seems I just can't use the symfony commands.

Symfony: Loading .env.test files

I thought this PR fixed the issue I am having - but I have this patch and it's still not working as I expected - what am I missing or mis-understanding?
https://github.com/symfony/symfony/pull/28533
I have created a .env.test with the following:
DATABASE_URL_TEST=mysql://apps:#localhost:3306/mydb_test
Then I dropped a doctrine.yaml inside the config/packages/test directory.
Symfony v4.2.3
However when I run this command from CLI:
APP_ENV=test bin/console doctrine:database:create --env=test
I am getting an error:
Environment variable not found: "DATABASE_URL_TEST".
Clearly the .env.test file is not being loaded - how do I get a specific environment configuration file to load - other than .env???
If indeed your application was a Symfony 3.x application at some point, what I would guess is that, during the upgrade process, those two lines out of the UPGRADE procedure were missed:
Then, upgrade the contents of your console script and your front
controller:
bin/console:
https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
public/index.php:
https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
Indeed, it seems like bin/console have been changed recently to reflect the adaptation done on the DotEnv component: https://github.com/symfony/recipes/commit/3e471cbc7d359b3ab245f3b0748d698e8d29692c#diff-2af50efd729ff8e61dcbd936cf2b114b
Mind that you'll also need https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php
I had a very similar problem. My issue was that my phpunit.xml.dist was pointing to the wrong bootstrap file:
Previously:
bootstrap="vendor/autoload.php"
Changed to:
bootstrap="tests/bootstrap.php"

symfony fatal error after removing bundle

I created a bundle named UserBundle and when I needed to remove it I did this exacly :
Unregister the Bundle in the AppKernel
Remove Bundle Configuration
2.1 Remove Bundle Routing
2.2 Remove Bundle Configuration
Remove the Bundle from the Filesystem
3.1 Remove Bundle Assets
Remove Integration in other Bundles
but when I try to exec soms command this is what I Get :
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in #UserBundle/Resources/config/s
ervices.yml (which is being imported from "C:\xampp\htdocs\MT\app/config\config.yml"). Make sure the "UserBundle/Resources/config/services.yml" bundle is correctly registered an
d loaded in the application kernel class. If the bundle is registered, make sure the bundle path "#UserBundle/Resources/config/services.yml" is not empty.
[InvalidArgumentException]
Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
[RuntimeException]
An error occurred when executing the ""cache:clear --no-warmup"" command:
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in #UserBundle/Resources/config/services.yml (which is being imported from "C:\xampp\htdocs\MT\app/config\config.yml").
Make sure the "UserBundle/Resources/config/services.yml" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "#UserBundle/Resources/config/services.yml" is not empty.
When I Refresh the server 'http://127.0.0.1/mt/web/' I get :
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?' in C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:198 Stack trace: #0 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php(232): Symfony\Component\HttpKernel\Kernel->getBundle('UserBundle', false) #1 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Config\FileLocator.php(51): Symfony\Component\HttpKernel\Kernel->locateResource('#UserBundle/Res...', NULL, false) #2 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php(147): Symfony\Component\HttpKernel\Config\FileLocator->locate('#UserBundle/Res...', 'C:\xampp\htdocs...', false) #3 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php(101): Symfony\Component\Config\Loader\FileLoader-> in C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php on line 179
In C:\xampp\htdocs\MT\app\config\config.yml you may have something like:
imports:
- { resource: #UserBundle/Resources/config/services.yml }
and possibly a configuration section related to the user bundle, i.e.
user_bundle:
...
You have to manually remove both to make everything working again.
Can you check if you use this bundle in app/config/service.yml
If it's not working, try to search with your IDE (integrated development environment) your bundle inside your project. If you find some results, just remove them.
Clear the cache
Try to clear cache manually by removing those folders : "var\cache\dev" and "var\cache\prod" for Symfony 3.x or "app\cache\dev" and "app\cache\prod" for Symfony 2.x .

Symfony deploying: RuntimeException in DebugClassLoader.php line 258:

Hello I have trouble by deploying my Symfony Projekt to my hoster.
I use: Symfony 2.8 with php 7.1.6
I do the following steps :
1. made a "composer update" on the project
2. cleaning the cache: "php app/console cache:clear -e prod"
3. Upload the files to the hoster
I copy the structure like on my system:
- htdocs-Folder
- app
- bin
- src
- vendor
- test
- web
When I open the website with: www.mydomaine.com/web/app_dev.php I get the following message:
screenshort - error message
Have anyone an idea why ?
THX
It was necessary to delete (make empty) the "prod"-cache folder manually, the command to clear the cache was not enough.

Symfony2 - Removed FOS User Bundle manually and now cannot clear cache in production mode

I installed FOS Userbundle to learn from it, but decided I didn't need it anymore. I then did the following to remove it. After removing, I ran composer update.
removed the bundle from the vendor folder
removed from the appKernel
removed from the composer.json file
removed the entity User.php file
removed the settings from config.yml, security.yml, routing.yml
Now when I attempt to clear cache for production mode I get the following error below. Clearing cache in dev mode works fine.
Can show me what I am doing wrong or what I am missing to remove FOS User Bundle and be able to clear cache in production mode?
PHP Fatal error: Class 'FOS\UserBundle\EventListener\LastLoginListener' not found in /var/www/html/HealthFitness/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php on line 142
PHP Stack trace:
PHP 1. {main}() /var/www/html/HealthFitness/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /var/www/html/HealthFitness/app/console:27
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/html/HealthFitness/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
PHP 4. Symfony\Component\DependencyInjection\Container->get() /var/www/html/HealthFitness/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:86
PHP 5. appProdProjectContainer->getEventDispatcherService() /var/www/html/HealthFitness/app/bootstrap.php.cache:2037
PHP 6. Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->addSubscriberService() /var/www/html/HealthFitness/app/cache/prod/appProdProjectContainer.php:343
Your error indeed probably come from a cache error.
Have you this error executing php app/console cache:clear --env=prod ?
You can else delete app/cache/prod/* manually.
In case you can't remove the files manually this should work as well.
You could also use a --no-warmup and --no-optional-warmers switches:
cache:clear --no-warmup --no-optional-warmers --env=prod
that way it should not try to recreate the cache of non existing classes and then do a
cache:warmup --env=prod
Manually removing cache is faster though, but you still warm it up.

Resources