Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning: imagettfbbox(): Could not find/open font in phar #519

Closed
JellyBellyDev opened this issue Dec 29, 2020 · 4 comments · Fixed by #683
Closed

PHP Warning: imagettfbbox(): Could not find/open font in phar #519

JellyBellyDev opened this issue Dec 29, 2020 · 4 comments · Fixed by #683

Comments

@JellyBellyDev
Copy link

Bug report

Question Answer
Box version 3.11.0
PHP version 7.4.13
Platform with version Docker image
Github Repo badges/poser#65

The compilation is successful and if I go to check the extracted dir all the content is correct, but if I go to use the phar it tells me that it cannot find a font file.
Below is a small screen where I also added a var_dump of the path of the processed file.
Where am I doing wrong?
Thanks

Schermata 2020-12-29 alle 13 40 31

@theofidry
Copy link
Member

You need to be aware that the file system works differently in a PHAR:

  • it is a read-only environment: you cannot add a file to the PHAR on the fly
  • realpath() is broken because any PHAR path is a virtual one

I am not 100% sure what your path should be (it's been a while since I had to deal with this issue) but it looks weird that you got an absolute path resolving to the PHAR file (i.e. /Users/jellybelly/github_xcom/poser/poser.phar): if it is the correct path then fine but otherwise that might be your lead in which case you would have two solutions:

  • use a relative path that would work fine in the PHAR
  • use a PHAR alias and have a different path when in a PHAR

@JellyBellyDev
Copy link
Author

Thanks @theofidry, now I try the two possible ways!
I will let you know!

@JellyBellyDev
Copy link
Author

@theofidry if i change the path of the font file to relative works correctly!
Is there any way to check if i am running with phar or not?
Example:

if(ENV_PHAR) {
  # use the relative path
} else { 
  # use the absolute path
}

Thanks

@theofidry
Copy link
Member

Apologies for the late reply. Hopefully you found your answer meanwhile. I added a doc entry for it still: https://github.com/box-project/box/blob/master/doc/faq.md#detecting-that-you-are-inside-a-phar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants