I want to perform an action from a custom command. The forward method Controller.php class provides this function, but I do not know access it from the execute () method of the command file
Making the controller a service will result in performance overhead because of the request stack, as it then should return a HttpResponse
. The Request
scope will not be very usefull in the command.
I'd advise you to refactor the action from the Controller to a separate service class definition, and get that class from the container in both the controller and the command by making it a ContainerAwareCommand
.
http://symfony.com/doc/current/cookbook/console/console_command.html#getting-services-from-the-service-container
Use controller as service How to Define Controllers as Service
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With