Skip to content

A Script that Speeds up the Process to Deploy PHP functions onto AWS Lambda

Notifications You must be signed in to change notification settings

zhumingcheng697/Bref-AWS-Setup

Repository files navigation

Bref-AWS-Setup

A Script that Speeds up the Process to Deploy PHP functions onto AWS Lambda.

How to Set Up

  1. Clone this repo.

    $ git clone https://github.com/zhumingcheng697/Bref-AWS-Setup.git
    
  2. Install serverless globally.

    $ npm install -g serverless
    
  3. Install other necessary node modules.

    $ npm install
    
  4. Configure serverless using AWS access keys.

    $ serverless config credentials --provider aws --key <key> --secret <secret>
    
  5. Install Composer globally.

  6. Install necessary PHP modules through Composer.

    $ composer install
    
  7. If you want to test out the email sending function and API, configure email.json.

    {
     "host": <your_host>,
     "port": <your_port>,
     "encryption": <your_encryption_method>,
     "username": <your_username>,
     "password": <your_password>
    }
    

    Property encryption accepts "ssl" and "tls", and defaults to null if unset.

  8. You are all set!

    • To start fresh, initiate a new Bref project.

      $ vendor/bin/bref init
      
    • To quickly deploy the PHP scripts you already have, move them to php-api/ and php-func/, run the script update-serverless-yml.js, and run serverless deploy.

      $ node update-serverless-yml.js
      $ serverless deploy
      

      or

      $ npm run predeploy
      $ serverless deploy
      

      or

      $ npm run deploy
      

NPM Scripts

  • Generate or update serverless.yml to prepare for deployment:

    $ npm run predeploy
    
  • Generate or update serverless.yml and deploy an AWS application with all the lambdas:

    $ npm run deploy
    

Warning: Only run these two scripts if all your PHP API scripts are in php-api/ and all your PHP function scripts are in php-func/, or the configuration for all your other PHP scripts will be discarded.

Serverless Commands

  • Deploy an AWS application with all the lambdas:

    $ serverless deploy
    
  • Invoke a lambda function:

    $ serverless invoke -f <function-name>
    
    $ serverless invoke -f <function-name> --data='{"key": "value", ...}'
    
  • Delete the AWS application with all the lambdas:

    $ serverless remove
    

About

A Script that Speeds up the Process to Deploy PHP functions onto AWS Lambda

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published