使用spatie / browsershot获取未找到类'App \ Http \ Controllers \ Manipulations'的错误

时间:2019-06-26 11:17:01

标签: laravel-5

使用pluhttps://github.com/spatie/browsershot我尝试将html内容保存为jpg文件,我需要在其中设置渲染图像 全高(可以在pdf文件的几页中生成内容)。 有办法吗,因为默认生成的图像是按高度切割的。

我尝试过:

    use Spatie\Browsershot\Browsershot;
    ...
    Browsershot::html( htmlspecialchars_decode($content) )
        ->showBackground()
        ->fit(\Manipulations::FIT_CONTAIN, 200, 200)
        ->save($save_to_file);

出现错误:

Class 'App\Http\Controllers\Manipulations' not found

我错过了哪些声明?我没有发现要在config / app.php中添加任何文字吗?

composer.json :
    "require": {
        "laravel/framework": "5.8.*",
        "spatie/browsershot": "^3.27",
        "spatie/laravel-image-optimizer": "^1.4",

package.json:
    "dependencies": {
        "puppeteer": "^1.14.0",
        "pusher-js": "^4.3.1"
    }

1 个答案:

答案 0 :(得分:1)

软件包spatie/browsershot有一个依赖项spatie/image软件包。

要解决您的问题,应将Manipulations类的路径添加到控制器中:

use Spatie\Image\Manipulations;