Possible to use inside a PHAR file?

138 views
Skip to first unread message

Uwe Keim

unread,
Dec 28, 2016, 6:18:14 PM12/28/16
to dompdf
Currently I'm failing to use dompdf inside my own PHAR file.

When it comes to create the Dompdf object, I get an error:

require(/lib/fonts/dompdf_font_family_cache.dist.php): failed to open stream: No such file or directory

My call stack is:

FontMetrics.php!Dompdf\FontMetrics->loadFontFamilies() Line 133
FontMetrics.php!Dompdf\FontMetrics->__construct() Line 72
Dompdf.php!Dompdf\Dompdf->__construct() Line 302
basket.php!{main} Line 6

I tried to do some workaround here. First, I thought about providing these options:

$options->set('temp_dir', 'TODO');
$options->set('font_dir', 'TODO');
$options->set('font_cache', 'TODO');

But I'm unsure whether this will ever work, because for these three options, in the source code it says:

The directory specified must be writeable by the webserver process

So I'm unsure how to proceed.


My question therefore:

Is there any advise on how to make your awesome library also work inside a PHAR file?

BrianS

unread,
Dec 29, 2016, 9:30:58 AM12/29/16
to dompdf
Your specific problem relates to how dompdf fetches resources and right now we haven't worked in support for PHAR files. I'm not sure when we'll get around to adding support, but you watch issue #621 for updates.

As for the requirements for write permissions, right now we do need that for some functionality (e.g. retrieving web-based resources such as images and stylesheets). It may be possible to make dompdf work in a read-only mode (e.g. temporarily persisting resource in memory), but it's not high on our list. Plus it would likely have a noticeable affect on performance and resource requirements.

Uwe Keim

unread,
Dec 29, 2016, 9:36:57 AM12/29/16
to dompdf
Thanks a lot, Brian.
Reply all
Reply to author
Forward
0 new messages