简体   繁体   English

Symfony 4:您请求的参数“区域设置”不存在

[英]Symfony 4: You have requested a non-existent parameter "locale"

When I enable the 'dev' mode in my Symfony 4 app (that is already online in a shared hosting service) it shows this message:当我在我的 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)
...

and does not allow to debug the app.并且不允许调试应用程序。 My config/services.yml code is as default:我的 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.
...

Please, someone can help me to fix this error.拜托,有人可以帮我解决这个错误。

Had the same problem during the fresh symfony 4.3 + sonata admin bundle installation.在新的 symfony 4.3 + 奏鸣曲管理包安装过程中遇到了同样的问题。 As a solution I added locale parameter:作为解决方案,我添加了 locale 参数:

// /config/services.yaml

parameters:
    locale: 'en' 

While I am not a Symphony expert the documentation appears to allow anything in the parameters section, but it does mention also defining the values in the .env.dist file as well for them to be used here.虽然我不是 Symphony 专家,但文档似乎允许参数部分中的任何内容,但它确实提到还定义了 .env.dist 文件中的值,以便在此处使用它们。

http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters

When upgrading from symfony 4.2 to symfony 4.4 I also got this error when composer commands.从 symfony 4.2 升级到 symfony 4.4 时,我在 composer 命令时也遇到了这个错误。

This parameter seems so be used in config/packages/translation.yml .这个参数似乎在config/packages/translation.yml中使用。 Updating the symfony/translation recipe which no longer refers to %locale% but hardcode 'en' solves the problem for me.更新不再引用 %locale% 但硬编码 'en' 的symfony/translation配方为我解决了这个问题。

Simply run composer recipes:install symfony/translation --force -v只需运行composer recipes:install symfony/translation --force -v

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony2:您已请求不存在的参数 - Symfony2: You have requested a non-existent parameter Symfony 4.1:你请求了一个不存在的服务“主义” - Symfony 4.1 : You have requested a non-existent service "doctrine" [Symfony2] [SwiftMailer]您请求的参数“ sender_name”不存在 - [Symfony2][SwiftMailer] You have requested a non-existent parameter “sender_name” Symfony2致命错误您请求的参数java_path不存在 - Symfony2 fatal error You have requested a non-existent parameter java_path 将 Symfony 3.4 更新到 Symfony 4.4 将返回您请求了一个不存在的参数“secret”。 你是说这个:“kernel.secret”吗? - Updating Symfony 3.4 to Symfony 4.4 returns You have requested a non-existent parameter "secret". Did you mean this: "kernel.secret"? 您尝试使用Symfony模板组件加载模板时,请求了不存在的参数“名称”错误 - You have requested a non-existent parameter “name” error when trying to load a template using Symfony templating component Symfony2:您请求的服务“ jms_aop.pointcut_container”不存在。 - Symfony2: You have requested a non-existent service “jms_aop.pointcut_container”. Symfony3您已请求不存在的服务“学说”。 MongoDB FOSUserBundle - Symfony3 You have requested a non-existent service “doctrine”. MongoDB FOSUserBundle 您已请求一个不存在的服务“ file.uploader”-Symfony3 - You have requested a non-existent service “file.uploader” - Symfony3 Symfony2 FOSUserBundle-您已请求一个不存在的服务“ security.user_checker” - Symfony2 FOSUserBundle - You have requested a non-existent service “security.user_checker”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM