You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, there's nothing special about the $output in a command. The service can instantiate one itself (as does Symfony by just newing-up a ConsoleOutput). This would eliminate the need for a setter, our services would become self-containing, the command would lose extra lines of code.
Furthermore, do not wrap calls to $this->output in a private method if the private method simply forwards a call to $this->output.
Some commands use services, which require
OutputInterface
to print messages to console. A common pattern is to do this:In a service:
And in a command:
However, there's nothing special about the
$output
in a command. The service can instantiate one itself (as does Symfony by just newing-up aConsoleOutput
). This would eliminate the need for a setter, our services would become self-containing, the command would lose extra lines of code.Furthermore, do not wrap calls to
$this->output
in a private method if the private method simply forwards a call to$this->output
.❌ This is bad:
✅ This is good:
The text was updated successfully, but these errors were encountered: