A Script that Speeds up the Process to Deploy PHP functions onto AWS Lambda.
-
Clone this repo.
$ git clone https://github.com/zhumingcheng697/Bref-AWS-Setup.git -
Install
serverlessglobally.$ npm install -g serverless -
Install other necessary node modules.
$ npm install -
Configure
serverlessusing AWS access keys.$ serverless config credentials --provider aws --key <key> --secret <secret> -
Install Composer globally.
-
On a Linux / Unix / macOS machine, install Composer locally and then move the downloaded
composer.pharto/usr/local/bin/composer.$ mv composer.phar /usr/local/bin/composer -
On a Windows machine, download and run Composer-Setup.exe as detailed on the Composer website.
-
-
Install necessary PHP modules through Composer.
$ composer install -
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
encryptionaccepts"ssl"and"tls", and defaults tonullif unset. -
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/andphp-func/, run the scriptupdate-serverless-yml.js, and runserverless deploy.$ node update-serverless-yml.js $ serverless deployor
$ npm run predeploy $ serverless deployor
$ npm run deploy
-
-
Generate or update
serverless.ymlto prepare for deployment:$ npm run predeploy -
Generate or update
serverless.ymland 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 inphp-func/, or the configuration for all your other PHP scripts will be discarded.
-
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