stackery / php-lambda-layer

PHP Runtime Layer for AWS Lambda
Other
321 stars 71 forks source link

SimpleXML not loading #36

Closed zkwbbr closed 5 years ago

zkwbbr commented 5 years ago

Hello, I have the following in php.ini:

extension=simplexml.so

However, it's not showing in phpinfo();.

To make sure php.ini is working, I tried loading another extension (e.g., extension=json.so), and it shows in phpinfo();

Any ideas how to make simplexml.so work? Thanks.

Note: I'm using layer:php73:2

txase commented 5 years ago

I don't think that extension is included by default. So, you'll need to compile it yourself into a separate layer. You can find details in the readme section talking about extensions.

I think the layer is working correctly, so I'm going to close this issue. But feel free to re-open if you think the layer isn't working correctly.

Thanks!

zkwbbr commented 5 years ago

According to the README simplexml.so is built into the layer.

txase commented 5 years ago

In adding support for PHP 7.3, I didn't notice the built-in list of extensions had changed. The first step I'll do is update the README to list the correct extensions per-version.

txase commented 5 years ago

The README is now updated. Sorry for the confusion.

I'd like to keep the built-in extensions to a minimum (everyone would like their own extensions in there, but it bloats the layer, which slows down cold starts). I suggest including simplexml in your own separate extension layer(s).

Please feel free to reopen if you disagree.

Thanks!

zkwbbr commented 5 years ago

Thanks. Can you kindly point me to instructions on how do add our own extension layers? Sorry can't seem to find info about this in the README. I'm just starting to checkout PHP lambda so it's not immediately clear how does one add a custom extension.

zkwbbr commented 5 years ago

To add, README says:

Extensions can be built using the lambci/lambda:build-nodejs8.10 Docker image. It is recommended that custom extensions be provided by a separate Lambda Layer with the extenadsion .so files placed in /lib/php/${PHP_VERSION}/modules/ so they can be loaded alongside the built-in extensions listed above.

Pardon me as I don't ask for spoon-feeding but this isn't clear on how exactly this supposed to be done.

txase commented 5 years ago

Yes, it's admittedly vague. The reason for that is PHP extensions can be built all kinds of ways. You might be able to do a simple rpm install (like you see in https://github.com/stackery/php-lambda-layer/blob/master/build-php-remi.sh#L21) that installs a package that has the extension pre-built. Then, all you have to do is zip that up (with the right folder hierarch) into a Lambda Layer.

But if there isn't an rpm package with the extension prebuilt, then you'll have to grab the source code somewhere and build it yourself.

And you want to build it inside a Docker container that matches the environment the lambda uses when it runs in AWS.

The goal is to have a zip package that looks like this:

/lib
  /php
    /7.3
      /modules
        simplexml.so
        myotherextension.so
        myotherextension2.so

I hope this helps, and I empathize. I don't think this is particularly simple, and there's no straightforward mechanism I'm aware of to make this easier.

zkwbbr commented 5 years ago

I'll check it out thanks!