gotenberg/gotenberg-php

Laravel 8

montanhes opened this issue · 11 comments

Does it works with Laravel 8?

I tried to install and use it, but I got the error below:

TypeError
Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, Nyholm\Psr7\Request given, called in ../vendor/laravel/framework/src/Illuminate/Http/Response.php on line 72 

Hello @ramonMontanhes

There is no reason it shouldn’t AFAIK 🤔 What exactly did you do?

@gulien I just installed it using composer and I tried to use the HTML string method:

use Gotenberg\Gotenberg;
use Gotenberg\Stream;

$request = Gotenberg::chromium($apiUrl)
    ->assets(
        Stream::path('/path/to/my.css'),
        Stream::path('/path/to/my.js')
    )
    ->html(Stream::path('/path/to/file.html'));

You may have to install the Nyholm PSR-7:

composer require nyholm/psr7

I did it (yesterday), and the problem remains.

@ramonMontanhes wimski/laravel-psr-http might be a solution. I was pretty sure it would work out of the box with Laravel, as it relies on the Symfony HTTP client 😅

I was able to use the gotenberg API calls with the existing Illuminate\Support\Facades\Http class. I'm using it for something simple and it's working. I just reported the issue to check if I'm doing something wrong or maybe to someone check if this is some bug.

Re @ramonMontanhes

So If I understand correctly, you're actually using the HTTP class from Laravel instead of gotenberg-php?

Yes. That was my workaround to get gotenberg working.

Makes sense 👍 that was my recommendation initially when I released Gotenberg v7 (i.e., to use the standard HTTP library of your stack), but folks still wanted a dedicated library 😄

I'll keep this issue open, just in case someone find the culprit.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.