This is a proof of concept (POC) application to demonstrate how to configure Serverless deployment with raw PHP.
In this project, I'm using the Bref and the Serverless Framework (AWS) with Node.js.
My objective is to show how you can configure your raw PHP application, rather than to implement the most beatiful code (kekw). Obviously, this configuration can be applied to PHP applications using any framework, although some settings may differ.
The application consists of checking if an email domain is valid. I'm using mock data to simulate blocked domains, just as an example to demonstrate how it works.
-
Node.js and NPM: Ensure that Node.js and NPM are installed in your environment.
-
AWS Account: You need an AWS account and an IAM user with the necessary credentials. If you don't know how to set this up, you can see the AWS IAM documentation.
Install the Bref plugin as a dependency using Composer:
composer require bref/bref --update-with-dependenciesInstall the Serverless Framework using NPM. Here’s how to install:
npm install -g serverlessAssuming you already have the necessary AWS credentials, configure them using the Serverless Framework. Run:
serverlessSelect option Skip Adding An App.
Chose Save AWS Credentials in a Local Profile and provide your access key and secret key to finalize the configuration.
Deploy your application with:
serverless deployAnd you’re all set!
- Make sure to replace placeholder values like
"your-key"and"your-secret"with your actual AWS credentials. - For more information, refer to the following resources:
Please ensure that Docker is installed on your local machine.
To build the container, execute:
docker compose up -dTo access the container as root, use:
docker compose exec -uroot app bashConfigure the Serverless Framework by using:
serverlessSelect the option Skip Adding An App.
Chose Save AWS Credentials in a Local Profile and provide your access key and secret key to complete the configuration.
To made deploy application, just run:
serverless deploy

