0

我正在用 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

这是配置子目录的屏幕截图。我认为我尊重标准: 这是配置子目录的截图

4

1 回答 1

0

缓存已成功预热,但还不够。为了工作,我也必须清除缓存。

在我的 composer.json 中,我为 post update 命令添加了一行:

  "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"
    ]
  },

添加的行是这一行:"cache:clear --no-warmup": "symfony-cmd"

此行在安装应用程序时不是必需的,但在更新期间需要。

于 2017-08-24T15:25:23.160 回答