ZeroSharp/serverless-php

Compile PHP with Mongodb/Postgress

Opened this issue · 4 comments

Thank you for this great work.

Do you know what needs to be done to compile php with Mongodb and Postgress support?

I have read that those modules need to be statically compiled and bundled into the compiled PHP, but I'm lost as to how to do it.

Best regards.

You need to modify dockerfile.buildphp to include your dependencies. (That is, add mongodb-org and postrgresql-server to the yum install part near the top. I'm no expert on php, so there's probably more to it than that...) Then run

sh buildphp.sh

which rebuilds your php binary.

Make sure your code works locally with

sls invoke local --function hello

This ensures your you've built your php correctly. If not keep modifying and building the php binary until it works. Then

sls deploy

and check it works remotely with

sls invoke --function hello

Hope that helps.

Hello.

Thank you for your answer.

Sure, yum install will install Mongodb and Postgres on the server, but don't you need to recompile PHP and let the compiler know that you want Mongodb and Postgres support?

Regards.

Yes buildphp.sh recompiles php. You need to modify buildphp.sh so that it builds your perfect php binary. You may need to change .configure or other changes in order to do so. To make sure you've got the right php binary, you can check it works locally before uploading anything to amazon as explained above with sls invoke local.

Have you got any chance to get Mongodb included in your php binary and get it working with Lambda? If you have done so, can you please help light me through... I am bumping into the same situation.

I want to include redis also because I want to use with Elasticache for Redis.

Thank you