我正在用 Flex 测试 Symfony。我有一个运行良好的非常小的应用程序(幸运数字生成器)。我想通过 Flex 添加 web_profiler。
我启动这个命令:
composer require web_profiler --dev
它工作正常,缓存已成功预热。但是当我查看我的主页时,出现了错误:“_wdt”路由不存在。
我检查了新config/routes/dev/web_profiler.yaml
文件。它是由 Flex 创建的。它包含:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
这似乎很好。我复制此代码并将其附加到我的config/routes.yaml
. 错误消失。我知道我的config/routes/dev
子目录中的 yaml 文件没有加载。
为什么我的文件/config/routes/dev subdirectory
没有加载?我忘记加载我的开发配置文件的哪一步?
这是我的.env
文件:
# 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 ###
这是我的config/routes.yaml
文件
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