gpt4 book ai didi

php - Symfony 未捕获异常 - 'The process has been signaled with signal "9"

转载 作者:行者123 更新时间:2023-12-04 22:37:55 31 4
gpt4 key购买 nike

我在尝试使用 Phantomjs 和 Symfony 的 Process 和 Reposonse 文件创建 PDF 文档时遇到此错误。

这是我收到的错误信息

fatal error :未捕获的异常 'Symfony\Component\Process\Exception\RuntimeException' 带有消息“进程已用信号“9”发出信号。

这是我的代码如下: Controller 文件

    namespace PhantomFox\Capture;

use PhantomFox\Views\View;
use Symfony\Component\Process\Process;
use Symfony\Component\HttpFoundation\Response;

class Capture
{
protected $view;
protected $pdf;

public function __construct()
{
$this->view = new View;
}

public function load($filename, array $data = [])
{
$view = $this->view->load($filename, $data);

$this->pdf = $this->captureImage($view);
}

public function respond($filename)
{
$response = new Response(file_get_contents($this->pdf), 200, [
'Content-Description' => 'File Transfer',
'Content-Disposition' => 'attachment; filename="' . $filename . '"',
'Content-Transfer-Encoding' => 'binary',
'Content-Type' => 'application/pdf',
]);

unlink($this->pdf);

$response->send();
}

protected function captureImage($view)
{
$path = $this->writeFile($view);

$this->phantomProcess($path)->setTimeout(10)->mustRun();

return $path;
}
protected function writeFile($view)
{
file_put_contents($path = 'app/tmp/storage/' . md5(uniqid()) . '.pdf' , $view);

return $path;
}

public function phantomProcess($path)
{
return new Process('app/bin/phantomjs capture.js ' . $path);
}

}

这是我的 View 文件:
class AppController extends Controller {

public function index() {

$this->capture->load('index.html', [
'order' => '123456',
'name' => 'Wes Murray',
'amount' => 100.00,
]);

$this->capture->respond('index.pdf');

}
}

最佳答案

根据这个帖子 The process has been signaled with signal "9"这可能与您的主机内存不足有关。

i.am.michiel 3 月 4 日 7:56

This might actually be a ressources problem. You might want to check your server's virtual hardware.



德米特里 3 月 4 日 11:56

@i.am.michiel , Thanks, virtual server just ran out of memory.



检查您的服务器设置和硬件是否适合您要运行的 PDF 操作类型。

关于php - Symfony 未捕获异常 - 'The process has been signaled with signal "9",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33146878/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com