Read the Bref Laravel documentation and make sure you have everything to get started first.
First, install the dependencies:
composer install --optimize-autoloader
Next, create a PlanetScale account and create a new database.
Finally, set up the database settings in .env
:
DB_CONNECTION=mysql
DB_HOST=<host url>
DB_PORT=3306
DB_DATABASE=<database name>
DB_USERNAME=<user>
DB_PASSWORD=<password>
The application can be deployed on AWS by running:
php artisan config:clear
serverless deploy
Now that Laravel is deployed, we can run php artisan migrate
in AWS Lambda to set up our tables:
serverless bref:cli --args="migrate --force"
For our demo, we can also seed the database with fake users:
serverless bref:cli --args="migrate:fresh --seed --force"
Read more about Laravel on Lambda in the official Bref documentation.