3
我目前正在使用PHP和Facebook API在Heroku上主持一個研究項目。它有點密集,所以它已經超過了Heroku 30秒的時間限制來回應。使用他們的支持,他們建議使用後臺進程來做到這一點(https://devcenter.heroku.com/articles/background-jobs-queueing),但他們沒有說我應該如何爲PHP做這件事。有沒有人有什麼建議?Heroku PHP託管超時
我目前正在使用PHP和Facebook API在Heroku上主持一個研究項目。它有點密集,所以它已經超過了Heroku 30秒的時間限制來回應。使用他們的支持,他們建議使用後臺進程來做到這一點(https://devcenter.heroku.com/articles/background-jobs-queueing),但他們沒有說我應該如何爲PHP做這件事。有沒有人有什麼建議?Heroku PHP託管超時
嘗試Symfony 2 process component。它有一個漂亮和簡單的面向過程的OO界面。
use Symfony\Component\Process\PhpProcess;
$command = file_get_contents('/hello_world.php');
if ($command) {
$process = new PhpProcess($command);
$process->run();
if ($process->isSuccessful()) {
$output = $process->getOutput();
// ...
}
else {
throw new Exception($process->getErrorOutput());
}
}
因此,我只是將我現在使用的代碼包含在一個文件中,在您的示例hello_world.php中,然後就像你說的那樣調用它,它不應該給我一個時間?我需要在Heroku上安裝Symfony 2還是已經可用? –
您需要[安裝process compontent](http://symfony.com/doc/2.0/components/process.html)到您的項目中。你不需要整個symfony2框架。你可以克隆[git repo](https://github.com/symfony/Process)或使用[composer](https://packagist.org/)。 – max
請把你下載的文件放在哪裏?我一直在獲取Class Symfony \ Component \ Process \ PhpProcess not found錯誤。 – Goaler444