Support the ongoing development of Laravel.io →
posted 3 years ago
Octane

I'm currently testing Laravel Octane. We're using Swoole.

Part of the app I'm testing generates PDFs. It does this on the fly, they are not stored. We present it as a download to the user.

The magic behind all this is Spatie's browsershot and some custom FPDi magic. We're not getting any errors, but where a file should be downloaded, the raw PDF data is displayed in the browser. The headers that were added are missing.

If I store the raw data, I get the PDF that I expected. It all works.

How can I make sure Octane uses the headers we'd like it to use for our PDFs?

Last updated 2 years ago.
0
Solution

Here's what happened: we're using FPDi, but not only to do some magic with our PDFs. It comes with built-in support to display inline PDFs and downloads. We're using that. Or in fact, we were using that. As we changed it.

FPDi uses plain PHP and headers for it. Apparently, Octane doesn't like that. Octane catches the request and passes it on to whatever server you're using (Swoole or RoadRunner). This needs to be a Response object. It wasn't.

So, problem solved!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ju5t ju5t Joined 11 May 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.