I am a newbie in Symfony. Anyhow I have found my way to build up a Console Command. So this command needs to be accessible from the frontend.
So by my opinion, I need to put the command to service. I have followed this link. So this should be created. But now I don't know how to connect this service to the actual route call. I have formed a route like this:
command:
path: /command
defaults:
_controller: AppBundle:Command:activate
requirements:
language: '%pimc.akeneo_cms.frontend.language.available%'
And I have created new controller called CommandController with just one method called activateAction(). And I don't know what to put in actiavateAction ?
Could someone help me ? Am I on a right path ?
You can follow these steps:
If you want to run a command in your controller's action, you can use Application
:
$application = new Application($this->get('kernel'));
$input = new ArrayInput(array('command' => 'your:command'));
$output = new BufferedOutput();
$application->run($input, $output);
And if you want to check the output of the command you can use $output->fetch()
.