当我在我的 Symfony 4 应用程序(已经在共享托管服务中在线)中启用“开发”模式时,它会显示以下消息:
(1/1) ParameterNotFoundException
You have requested a non-existent parameter "locale".
in ParameterBag.php (line 100)
at ParameterBag->get('locale')
in EnvPlaceholderParameterBag.php (line 57)
at EnvPlaceholderParameterBag->get('locale')
in ParameterBag.php (line 216)
at ParameterBag->resolveString('%locale%', array('locale' => true))
in ParameterBag.php (line 187)
...
Run Code Online (Sandbox Code Playgroud)
并且不允许调试应用程序。我的 config/services.yml 代码是默认的:
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: 'en'
services:
# default configuration for Services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your Services.
autoconfigure: true # Automatically registers your Services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused Services; this also means
# fetching Services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
...
Run Code Online (Sandbox Code Playgroud)
拜托,有人可以帮我解决这个错误。
在新的 symfony 4.3 + 奏鸣曲管理包安装过程中遇到了同样的问题。作为解决方案,我添加了语言环境参数:
// /config/services.yaml
parameters:
locale: 'en'
Run Code Online (Sandbox Code Playgroud)
虽然我不是 Symphony 专家,但文档似乎允许参数部分中的任何内容,但它确实提到还定义 .env.dist 文件中的值以及在此处使用它们。
http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters
| 归档时间: |
|
| 查看次数: |
7787 次 |
| 最近记录: |