1

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 ?

Thomas Crawford
  • 886
  • 2
  • 15
  • 45

4 Answers4

2

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
Cristian Bujoreanu
  • 1,147
  • 10
  • 21
1

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

Community
  • 1
  • 1
Jason Roman
  • 8,146
  • 10
  • 35
  • 40
0

Maybe it will be enough to use plain php exec function.

asyndrige
  • 572
  • 6
  • 23
0

You can define the command as a service like this and use it in your controller.

mangelsnc
  • 76
  • 5