My question here boils down to whether what I'm doing in and of itself is wrong or whether I have discovered a bug. I'm simply not sure...
What did I do? We have a relatively normal application based on Symfony 2.8. There, we also use the usual service container. Also, for maintenance, we define a bunch of commands to call on the commandline. During development, I added another parameter to the constructor of a class which is used in one of these commands.
The problem I have now is that I can't properly deploy this. When I just replace the code and call app/console cache:clear
to regenerate the cached service container from the services definition, because on startup, the kernel tries to instantiate all commands using the cached service container. Since the cached service doesn't provide the new parameter but the changed code requires the parameter, startup fails.
Further observations:
- The command extends the
setContainer()
method from the baseclass to retrieve its own dependencies. In this case, one commands fails to retrieve its dependencies from the service container. I'm wondering ifsetContainer()
is too early -- If I postponed this toexecute()
, this would only fail when the command is actually invoked but not whencache:clear
is invoked. - I'm also thinking that Symfony shouldn't abort startup if initialization of some command fails. It should alert the user but continue loading other commands. Even more, it shouldn't even load commands that aren't used.
- In my particular case, I think that just not loading that command (or skipping it on error) would do the job, but I'm not sure if that is always the case.
- As workaround, I can of course delete the cache folder. But what's the point of a
cache:clear
command if that doesn't work?