I am trying to deploy a Laravel application to App Engine Flexible environment with a custom PHP runtime. When I try to generate a PDF on the site (using wkhtmltopdf with the laravel-snappy wrapper) I get the error: (1/1) LogicException
The Process class relies on proc_open, which is not available on your PHP installation.
in Process.php line 143
at Process->__construct(array(), null, null, null, 60.0)in Process.php line 195
at Process::fromShellCommandline('/app/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality \'/tmp/knp_snappy5dc8497d489631.19576754.html\' \'/tmp/knp_snappy5dc8497d489f90.93505253.pdf\'', null, null)in AbstractGenerator.php line 520
at AbstractGenerator->executeCommand('/app/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality \'/tmp/knp_snappy5dc8497d489631.19576754.html\' \'/tmp/knp_snappy5dc8497d489f90.93505253.pdf\'')in AbstractGenerator.php line 176
The thing is, though, I have proc_open and proc_closed listed in the whitelist_functions line in my app.yaml.
Here is a snippet from my app.yaml:
runtime: custom
env: flex
api_version: 1
runtime_config:
document_root: public
whitelist_functions: proc_open,proc_close
For the sake of trying other approaches, I've also tried including it in a php.ini:
google_app_engine.enable_functions = "php_sapi_name,php_uname,getmypid,proc_open, proc_close"
google_app_engine.disable_functions ="exec,passthru,shell_exec,show_source,symlink,system"
Yet I still get the error above.
In case it's relevant, I'll also show my Dockerfile:
FROM gcr.io/google-appengine/php
COPY ./ /app
RUN mkdir -p /app/storage/framework/cache \
mkdir -p /app/storage/framework/cache/data \
mkdir -p /app/storage/framework/views \
mkdir -p /app/storage/framework/sessions \
mkdir -p /app/storage/logs
RUN chmod -R a+rwX /app/storage
RUN chmod a+rwx /app/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64
ENV DOCUMENT_ROOT /app/public
RUN apt-get update && apt-get -y install libfontconfig1 libxrender1 libxext6 libssl-dev libssl1.0 libjpeg62 libpng16-16
EXPOSE 8080
... and the relevant bits from my composer.json:
"require": {
"php": ">=7.2.9",
"laravel/framework": "^6.0",
"google/cloud": "^0.24.0",
"superbalist/laravel-google-cloud-storage": "^2.0",
"barryvdh/laravel-snappy": "^0.4.3",
"h4cc/wkhtmltopdf-amd64": "0.12.x",
"h4cc/wkhtmltoimage-amd64": "0.12.x"
},
Am I missing something?
Update: I'm not sure if this is related, or just another error I'll need to deal with next, but if I attempt to run wkhtmltopdf directly from the command line, I get error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
But I can't install that because it does not appear to be available for the version of Linux I'm using (Ubuntu 16.04.6).
You can check this example: How to use the image on App Engine Flexible Environment:
If you need any of those functions, you can add an environment variable WHITELIST_FUNCTIONS.
app.yaml:
runtime: php
vm: true
api_version: 1
env_variables:
WHITELIST_FUNCTIONS: phpinfo,exec