Answer the question
In order to leave comments, you need to log in
How to change a parameter in Symfony2?
Hello! Tell me, please, how can I set the parameter specified in the yaml config
parameters:
app_main.city: Анадырь
$this->container->setParameter('app_main.city', 'Канчалан')
Impossible to call set() on a frozen ParameterBag.
Answer the question
In order to leave comments, you need to log in
And where are you trying to set the parameter? and must be set in the bundle configurator - in the DependencyInjection\YourBundleExtension class. After that, the container is frozen and cannot be changed. If you need it, then you are doing something wrong in the architecture.
If you need to change a parameter at the development level, put the desired value in parameters.yml (replace Anadyr with Kanchalan). And if the desired value is determined in the code, then it does not need to be set in the container parameter, it must be passed through the arguments of the service method.
Tell us in more detail what your task is, so that you can tell in more detail.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question