Symfony2 - process launching a symfony2 command

后端 未结 2 1092
鱼传尺愫
鱼传尺愫 2021-01-22 10:43

My goal is to launch some time consuming functions in the background to avoid user to wait before the server response is rendered.

I have a Symfony project where I am la

相关标签:
2条回答
  • 2021-01-22 10:52

    I found a workaround to this problem using exec instaed of creating a new Process object.

    exec('/usr/bin/php '.$this->get('kernel')->getRootDir().'/console scopusftpupload ' . escapeshellcmd($params) . ' > /dev/null 2>&1 &');
    
    0 讨论(0)
  • 2021-01-22 10:52

    We do our asynchronous processing with Gearman job server - http://gearman.org/

    There are bundles that streamlines the use of Gearman in a Symfony project. We use mmoreram/GearmanBundle - https://github.com/mmoreram/GearmanBundle. Basically, you create your worker, which can be a service, and call it for time consuming tasks. We use it for data imports that take long time.

    0 讨论(0)
提交回复
热议问题