Symfony2的 - 过程中推出的Symfony2命令 [英] Symfony2 - process launching a symfony2 command

查看:177
本文介绍了Symfony2的 - 过程中推出的Symfony2命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是推出一些时间在后台消费功能,以避免用户等待服务器的响应呈现前。

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

我在那里,我从控制器启动异步进程symfony项目。这个过程将推出Symfony的命令,将调用另一个控制器。

I have a Symfony project where I am launching an asynchronous process from a controller. This process will launch a Symfony command that will call another controller.

问题是,当我打电话与)的过程中开始(

The problem is when I am calling the process with start()

$process = new Process('/usr/bin/php '.$this->get('kernel')->getRootDir().'/console scopusftpupload ' . escapeshellcmd($params));
$process->start();

然后什​​么也没有发生的过程,但重定向和其他一些code,我有后来的作品。

Then nothing happens with the process, but the redirect and some other code that I have later works.

但是,如果我这样做

$process->run();

接着,处理工作正常,但我需要等到proceess为了渲染视图完成了。

Then the process works fine, but I need to wait until the proceess finished in order to render the view.

任何想法,我做错了?

推荐答案

我发现了一个变通方法来使用EXEC这个问题instaed创建新进程的对象。

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 &');

这篇关于Symfony2的 - 过程中推出的Symfony2命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆