Giter Site home page Giter Site logo

zerosharp / serverless-php Goto Github PK

View Code? Open in Web Editor NEW
145.0 10.0 20.0 25.83 MB

Serverless Framework example using an AWS lambda which runs a PHP function

License: Other

Shell 36.59% JavaScript 53.47% PHP 9.94%
php aws-lambda serverless-framework

serverless-php's Introduction

PHP with the Serverless Framework

In order to use PHP on AWS Lambda you need to bundle the PHP binary, including the required libraries, into the package. This serverless example project includes the necessary binary to run a simple PHP script.

See my blog post here.

Prerequisites

Install this serverless project. It will create a new serverless-php folder.

serverless install --url https://github.com/ZeroSharp/serverless-php

Deploying the sample function to AWS

Check the serverless.yml file and modify region and stage if necessary.

sls deploy

Running the function locally

sls invoke local --function hello

Running the function on AWS

sls invoke --function hello

Rebuilding the PHP binary

If you need different compiler flags or dependencies you will need to recompile PHP.

Prerequisites

Compile the static standalone PHP 7 binary

To do this, we have to compile the PHP 7.2.2 with statically linked libraries:

sh buildphp.sh

PHP Version

The default is to use the PHP 7.2.2 branch to compile the PHP binary. To switch the PHP version you can set the branch PHP_VERSION_GIT_BRANCH parameter in buildphp.sh line 8.

Thanks

Thanks to:

serverless-php's People

Contributors

oh-sky avatar shamp00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-php's Issues

SLS deploy not working anymore after nodjes6 deprecation

After the NodeJS 6 deprecation by AWS the serverless deploy no longer works.

The runtime configured to NodeJS 6.10 in serverless.yml:

[...]
provider:
  name: aws
  runtime: nodejs6.10
[...]

Causes the following error on Serverless deploy

$ serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
........
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service xxx-serverless-php.zip file to S3 (3.92 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
................
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stack/detail?stackId=xxxxxxxxxxxxx

  Serverless Error ---------------------------------------

  An error occurred: HelloLambdaFunction - The runtime parameter of nodejs6.10 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs12.x) while creating or updating functions. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx).

Compile PHP with Mongodb/Postgress

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.

not able to run php script from the php file

I would like running script from the php file,
like

$command = '/opt/exemple/exemple run api';
system($command);

It seems doesn't work,
just commands which display output like system('ls'); works

Compile causes libpng error

Hello there. I was trying to recompile the PHP binary with the --enable-dom flag and after it completed trying to execute the binary on my local machine or on a lambda resulted in the error:

php: error while loading shared libraries: libpng15.so.15: cannot open shared object file: No such file or directory

Wondering if there was something I was missing?

libcurl problem after building PHP

After building PHP 7.1.0 and deploying to Lambda, I get the following error when executing my function:

stderr: ./php: /usr/lib64/libcurl.so.4: no version information available (required by ./php)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.