Laravel 5.1 在 handle() 中对未定义的函数进行排队,但在构造函数中工作



我使用Laravel5.1队列来处理大图像。我有一个非常奇怪的行为,因为当我在构造函数中调用函数"imagettfbbox"时,它可以工作。但显然我需要让它在"句柄"中工作,但我遇到了一个错误。

public function __construct()
{
    //TEST
    $font_path = public_path('/fonts/roboto/Roboto-Thin.ttf');
    imagecreate(10,10); //works!
    imagettfbbox(10, 0, $font_path, 'test'); //works!
}
public function handle() //GenerateImage $generator, Image $img
{
    //TEST
    print 'OK'; //gets printed
    $font_path = public_path('/fonts/roboto/Roboto-Thin.ttf');
    imagecreate(10,10); //works!
    imagettfbbox(10, 0, $font_path, 'test'); //CRASHES!
}

我打印了"确定",然后出现错误"调用未定义的函数App\Jobs\imagettfbbox()"。这是一种非常奇怪的行为,因为某些图像功能在其他图像功能中不起作用。我已经安装了GD,并且在处理代码的任何地方都可以正常工作。知道我在这里错过了什么吗?

也许你缺少imagettfbbox所需的FreeType库

最新更新