php-phantomjs icon indicating copy to clipboard operation
php-phantomjs copied to clipboard

Procedure::run should allow custom export variables

Open andrewfenn opened this issue 8 years ago • 0 comments

Using Ubuntu linux as an example you may find yourself in need of defining custom bash variables before running the PhantomJS command.

The specific issue I ran into was that I needed to define the following..

# define how QT renders in PhantomJS
export QT_QPA_PLATFORM=offscreen
# define where fonts are loaded from (fixes issues rendering chinese fonts in screenshots)
export QT_QPA_FONTDIR=/usr/share/fonts

Currently what I've done to get around this is to simply change Procedure::run, proc_open call like so...

$process = proc_open('export QT_QPA_PLATFORM=offscreen; export QT_QPA_FONTDIR=/usr/share/fonts;'.escapeshellcmd(sprintf('%s %s', $this->engine->getCommand(), $executable)), $descriptorspec, $pipes, null, null);

As you can see I simply prepended them on a string. I think it would be good in the future if there was an interface for being able to define this without having to custom hack the code though.

andrewfenn avatar Sep 07 '17 10:09 andrewfenn