NucleosDompdfBundle icon indicating copy to clipboard operation
NucleosDompdfBundle copied to clipboard

Docker caveat

Open kl3sk opened this issue 1 year ago • 0 comments

Question and answer

Hello, I faced the problem with loading image as seen in this issue. All fixes were made without any success. But after a repairing night, the solution come to me, so I would like to share it with you.

I've read lot of issues here and on DomPDF repo as well. I saw on the DomPDF options that ext_curl or allow_url_fopen should be enabled, so images where not loaded directly by the web server but by the PHP engine.

And because I'm using docker with to separate container it could nerver work.

This couldn't be fix on the package but a notice can be set.

Using docker-compose on {{ absolute_url(asset( <image path> )) }} I just replace the host (localhost in my case) with the "linked" container name (web in my case).

A simple {{ absolute_url(asset( <image path> ))|replace({'localhost': 'web'}) }} fix my problem.

In fact this solution should be per project, I personally create a Twig extension that replace it only on Dev env.

kl3sk avatar Mar 03 '23 09:03 kl3sk