Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Extension not loaded #40

Open
danieljosephbrennan opened this issue Jun 12, 2019 · 3 comments
Open

Extension not loaded #40

danieljosephbrennan opened this issue Jun 12, 2019 · 3 comments

Comments

@danieljosephbrennan
Copy link

I am getting this error: "Use of undefined constant XML_PI_NODE - assumed 'XML_PI_NODE' (this will throw an Error in a future version of PHP)"
This seems to indicate that the xml extension is not loaded, but I have added it to php.ini

@JDJunge
Copy link

JDJunge commented Jun 13, 2019

I ran into a surprisingly similar issue just yesterday.
My mysql extension was not loaded.

I guess the php.ini file is in the wrong directory. In the resulting lambda-layer it will be found under /opt/php.ini but the bootstrap will search for it somewhere else.

I changed
exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.${phpMinorVersion}.d/:/var/task/php-7.${phpMinorVersion}.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.${phpMinorVersion}/modules '$handler_filename'");

To
exec("PHP_INI_SCAN_DIR=/opt/ php -S localhost:8000 -c /opt/php.ini -d extension_dir=/opt/lib/php/7.${phpMinorVersion}/modules '$handler_filename'");

Now extensions are beeing loaded (confimed via phpinfo())

@silvian-io
Copy link

Hi there. So i bumped into the same issue also, trying to install a PHP layer on my dumb AWS lambda function(I needed the json and mbstring modules). In my case, the above solution didn't work, as I was getting a permission denied error:

RequestId: xxxxxxxxx Error: Runtime failed to start: fork/exec /opt/bootstrap: permission denied
Runtime.ExitError

The solution was to update the exec line to:

exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.${phpMinorVersion}.d/:/var/task/php-7.${phpMinorVersion}.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.${phpMinorVersion}/modules '$handler_filename'");

and add the php.ini file, that includes all the modules I need, at the top level of my lambda function folder, next to all the other files. As the lambda env runs at /var/task , setting the path at /var/task/php.ini worked for me.

Extensions are loaded now.

Hope this helps. All the best

@zilahir
Copy link

zilahir commented Sep 9, 2019

The extensions are not loaded for me either, and don't know how to approach this problem.

I am getting the following error in the logs.

[Mon Sep 9 16:11:29 2019] PHP Warning: PHP Startup: Unable to load dynamic library 'xml.so' (tried: /opt/lib/php/7.3/modules/xml.so (/opt/lib/php/7.3/modules/xml.so: cannot open shared object file: No such file or directory), /opt/lib/php/7.3/modules/xml.so.so (/opt/lib/php/7.3/modules/xml.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

According to the docs, the modules should be there, but apparently they are not.

Any ideas, suggestions? Thanks in advance!

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

No branches or pull requests

4 participants