Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works locally, but fails on AWS Lambda :( #15

Open
mohitkale opened this issue Jun 29, 2018 · 5 comments
Open

Works locally, but fails on AWS Lambda :( #15

mohitkale opened this issue Jun 29, 2018 · 5 comments

Comments

@mohitkale
Copy link

Dear Author,

Please help.

I have successfully installed and configured serverless-php on both local and AWS Lambda. The function works as expected locally but does not work when it is invoked over AWS Lambda.

When invoked locally, the execution is SUCCESSFUL. https://www.screencast.com/t/KfIVnmRdVOF

When invoked online, the execution FAILS. https://www.screencast.com/t/ptootyYsFATF

When executed from AWS Lambda, it FAILS. https://www.screencast.com/t/qxFTk77X2

Looks like the child process call from the handler.js file is not getting executed for some reason.
var proc = child_process.spawn(php, args, options);

My local system is a Windows 10 x64 machine. Not sure if it has anything to do with Windows.

I tried to find a solution for this but a lot of other people are also struggling in getting it to work properly. Please help me fix this issue.

Suggestion: If possible please do a video tutorial of getting serverless-php up and running for Windows 10.

Looking forward to an early response.

Thanks & regards,
Mohit

@araines
Copy link
Owner

araines commented Jun 29, 2018

Based on the error message you are getting (Error: spawn EACCES) my guess would be that the PHP binary packaged and deployed to AWS Lambda does not have execute permission. On *nix systems this is a pretty easy thing to fix (ensure it has the +x flag via chmod - e.g. chmod a+x php). However, I have no experience with doing this with Windows at all.

The reason it is executing locally is because the Javascript wrapper uses your local system PHP binary when executing locally. Only once you are within the AWS Lambda environment will it use the PHP binary within the repository.

You may be able to get somewhere with cygwin or similar (assuming that project still exists?) to get good old *nix power in a Windows environment.

I assume you have already done this, but in case not -- as per the README, please ensure you have rebuilt the PHP binary via Docker or downloaded it directly from GitHub to ensure the file actually is a real binary file! Otherwise it definitely won't be executable.

@araines
Copy link
Owner

araines commented Jun 29, 2018

Actually this looks like a duplicate of the outstanding #10 - basically someone else having a problem with getting executable flags on files within Windows.

@araines
Copy link
Owner

araines commented Jun 29, 2018

Also if you do get this working, please do feedback how - it would be great to get the additional info on the README for those unfortunate enough to have to use Windows ;-).

@robertcharlesfox
Copy link

robertcharlesfox commented Aug 15, 2018

Hi @araines I had somewhat of a similar issue. I was trying to use the AWS S3 classes through your Serverless / Lambda configuration. At first it was working when invoked locally, but not when invoked on Lambda remotely. Kept saying that filter_vars function was undefined. My sysadmin figured out that we needed to add --enable-filter and rebuild the PHP file. That solved my problem.

Anyway, thanks for contributing this project, it looks like it has potential to be extremely useful! I have only just gotten started using it and look forward to getting deeper.

"errorMessage": "Process error code 255: \nFatal error: Uncaught Error: Call to undefined function Aws\S3\filter_var() in /var/task/aws/Aws/S3/S3Client.php:314

@araines
Copy link
Owner

araines commented Aug 16, 2018

Hi @robertcharlesfox thanks for the input - I think the issue you were facing was a little different to the one reported. Functions being undefined within PHP is very much down to the compiled libraries through the flags in the dockerfile, as you've rightly identified. :)

However, the issue here seems to be specifically to do with actually executing the PHP binary once deployed to Lambda from a Windows machine.

Either way, thanks for contributing and I'm glad this project is helping solve some problems for you!

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

No branches or pull requests

3 participants