barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.59k stars 289 forks source link

Bug - The output file scheme is not supported. #512

Open vladutt opened 10 months ago

vladutt commented 10 months ago

Hello. On version 1.4.3 of knplabs/knp-snappy we got this error.

The output file scheme is not supported. Expected '' or 'file' but got 'c.

The solution was to change the version back to 1.4.1

Also we tried to update version of laravel-snappy as well to 1 from 0.4.8, but without any results.

Server: Windows IIS PHP: 8.1.13

mfzpeyo commented 9 months ago

Knp\Snappy\AbstractGenerator.php Line: 629

Generated file name C:\Windows\Temp\test.html

array:2 [▼ // routes\ext.routes\dev.php:12
  "scheme" => "C"
  "path" => "\Windows\Temp_est.html"
]
 protected function prepareOutput($filename, $overwrite)
    {
        if (false === $parsedFilename = \parse_url($filename)) {
            throw new InvalidArgumentException('The output filename is invalid.');
        }

        $scheme = isset($parsedFilename['scheme']) ? \mb_strtolower($parsedFilename['scheme']) : '';
nepos87 commented 9 months ago

Same bug with 1.4.8 version and PHP: 7.4

Any solution?

nepos87 commented 9 months ago

Tested with all versions of 0.4.* and get the same error

vladutt commented 9 months ago

Tested with all versions of 0.4.* and get the same error

on 1.4.1 can't be the same error. Because the code which check schema it's not present. Test carefully what version did you installed. Maybe you can try to delete vendor and composer-lock.json.

In your composer the package should be without '^'. like this "knplabs/knp-snappy": "1.4.1",

KleinDevDE commented 9 months ago

I have the same problem. However, the bug itself belongs to KnpLabs/snappy and not barryvdh/laravel-snappy. See: https://github.com/KnpLabs/snappy/issues/489

A bug fix is already in the works and will be in the next release. The last version took 6 months, so I can't say when this will happen.

Workaround

So here is a workaround that works just as well. Add the following line to your composer.json require block: "knplabs/knp-snappy": "1.4.2 as 1.4.3". This will map version 1.4.3 to version 1.4.2.

After that, you need to do one of the following things:

alexpozzi commented 9 months ago

I should be able to release a fix this week. The fix is ready and it's waiting for couple more reviews https://github.com/KnpLabs/snappy/pull/490 Feel free to review it yourself, sorry for the issue.

alexpozzi commented 9 months ago

Fix released, I've added a test pipeline for Windows to avoid OS related issues to happen again.

nepos87 commented 9 months ago

It works now, thanks!