Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

symfony

When I enable the 'dev' mode in my Symfony 4 app (that is already online in a shared hosting service) it shows this message:

(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:

# 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.

like image 292
Ivan Triviño Avatar asked Dec 24 '22 10:12

Ivan Triviño


1 Answers

Had the same problem during the fresh symfony 4.3 + sonata admin bundle installation. As a solution I added locale parameter:

// /config/services.yaml

parameters:
    locale: 'en' 
like image 134
MilanG Avatar answered Dec 26 '22 15:12

MilanG