Impossible to call set() on a frozen ParameterBag

You can't modify Container once it has been compiled, which is done before invoking the controller.

The DIC parameters are intended for configuration purposes - not a replacement for global variables. In addition it seems you want to persist some kind of permanent modification. In that case consider using session if it's a per-user modification or persisting it (e.g. into DB) if it's supposed to be application-wide.

If you need to modify DIC parameters or services, you can do so using a compiler pass. More info on how to write custom compiler passes can be found at: http://symfony.com/doc/master/cookbook/service_container/compiler_passes.html

Tags:

Symfony