I'm testing Symfony with Flex. I have a very small application which is working fine (the lucky number generator). I want to add the web_profiler via Flex.
I launch this command:
composer require web_profiler --dev
It works fine, cache is succesfully warmed up. But when I check my homepage, an error occured: The "_wdt" route does not exist.
I checked the new config/routes/dev/web_profiler.yaml
file. It was created by Flex. It contains:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
It seems to be good. I copy this code and append it to my config/routes.yaml
. The error disappear. I understood that my yaml files in the config/routes/dev
subdirectories are not loaded.
Why my files in /config/routes/dev subdirectory
are not loaded ? Which step did I forget to load my dev config files ?
Here is my .env
file:
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=80b8077a9ccaaf2b5dd3427b512bae42
###< symfony/framework-bundle ###
Here is my config/routes.yaml
file
index:
path: /
defaults: { _controller: 'App\Controller\GeneratorController::numberAction' }
# Depends on sensio/framework-extra-bundle, doctrine/annotations, and doctrine/cache
# install with composer req sensio/framework-extra-bundle annot
controllers:
resource: ../src/Controller/
type: annotation
This is the screenshot of the config subdirectories. I think that I respect standards:
Cache was succesfully warmed up, but it is not enough. To works, I have to clear the cache too.
In my composer.json, I added a line for the post update commands:
"scripts": {
"auto-scripts": {
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
"security:check": "symfony-cmd",
"cache:clear --no-warmup": "symfony-cmd",
"cache:warmup": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
The line added is this one : "cache:clear --no-warmup": "symfony-cmd"
This line is not necessary when installing application, but it is needed during an update.