Closed Cvar1984 closed 4 years ago
@Cvar1984 Thanks for filing this question!
It looks like your application is not prepared to work with paths within your phar archive. The most straight-forward way to make it work is by using paths that are relative to __FILE__
or __DIR__
(which will automatically be prefixed with phar://
when run from within a phar).
For example, you can load a file relative to your current path like this to support both normal filesystem operations as well as operation within Phars:
$content = file_get_contents(__DIR__ . '/font.ttf');
I hope this helps :+1:
Thanks
How to insert my assets file to my single executable phar?
u0_a115@localhost:~$ ls simpleimage/ assets build composer.json composer.lock index.php src vendor u0_a115@localhost:~$ php simpleimage.phar
Warning: imagettfbbox(): Invalid font filename in phar:///data/data/com.termux/files/home/simpleimage.phar/vendor/claviska/simpleimage/src/claviska/SimpleImage.php on line 928
Call Stack: 0.0600 641280 1. {main}() /data/data/com.termux/files/home/simpleimage.phar:0 0.0613 648120 2. include('phar:///data/data/com.termux/files/home/simpleimage.phar/index.php') /data/data/com.termux/files/home/simpleimage.phar:9 0.0809 980528 3. Gambar->__construct(???, ???, ???, ???, ???) phar:///data/data/com.termux/files/home/simpleimage.phar/index.php:71 0.3324 1287192 4. claviska\SimpleImage->text(???, ???, ???) phar:///data/data/com.termux/files/home/simpleimage.phar/index.php:56 0.3333 1287888 5. imagettfbbox(???, ???, ???, ???) phar:///data/data/com.termux/files/home/simpleimage.phar/vendor/claviska/simpleimage/src/claviska/SimpleImage.php:928 Unable to load font file: phar:///data/data/com.termux/files/home/simpleimage.phar/assets/FSEX300.ttf
u0_a115@localhost:~$