CakePHP: Run shell job from controller

后端 未结 6 786
难免孤独
难免孤独 2020-12-09 06:06

Is it possible to use dispatchShell from a Controller?

My mission is to start a shell job when the user has signed up.

I\'m using CakePHP 2.0

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 06:59

    If this is to intialize AclExtras the best way is:

    App::import('Console/Command', 'AppShell');
    App::import('Plugin/AclExtras/Console/Command', 'AclExtrasShell');
    
    $job = new AclExtrasShell();
    $job->startup();
    $job->dispatchMethod('aco_sync');
    

    But avoid this unless you have no possibilities to run the console script.

提交回复
热议问题