Reputation: 896
i have this console command :
php app/console jms-job-queue:run
I want to run this command when i click a button on my website. So i don't niet a command prompt to do this.
Is this possible in symfony 2 ?
Upvotes: 1
Views: 1469
Reputation: 148
You can define the command as a service like this and use it in your controller.
Upvotes: 0
Reputation: 1167
A good idea would be to created a helper class to do this for you, because the commands will look different foreach dev and prod environment. You can add also methods to check if there are any processes running, or to kill one.
Not sure, but I guess you need full path to your command:
[%kernel.root_dir%] / console jms-job-queue:run
Upvotes: 2
Reputation: 8276
Your could try creating a service that defines the behavior you want, then have both your console command and your controller action call that service. This promotes code reuse and allows you to call that function anywhere you want.
You can also look at this question that had been answered before: How can I run symfony 2 run command from controller
Upvotes: 1