A Real World PHP Lambda App

Submitted by nigel on Sunday 26th November 2017

My previous blogs on AWS Lambda, PHP, Serverless and Serverless-PHP should have given you enough of a basic understanding of the mix of technologies to attempt to build something much more useful - a fully fledged PHP app. 

What would be the motivation for doing this? What type of sites lend themselves to be built with Serverless? 

Well certainly nothing on a grand scale - it would be foolhardy to attempt to host the BBC website on Lambda!! However Lambda lends itself to websites that may be immensely popular over a relatively short period of time. These could include (but are not limited to)

  • News announcements for significant events (e.g. Oscar results for instance)
  • Promotional websites for new products
  • Registration / statement of interest sites
  • Advocacy / campaigns
  • Questionnaires / surveys / voting

Any small site that has the possibility of incurring scaling problems, significant orchestration and deployment costs is a candidate. Furthermore once the promotion has served its purpose, the site could be re-skinned for re-use at a later date. 

Why PHP? If you already have PHP skills, or your work department does, then it frequently makes sense to standardise skills when building out products. 

The tutorials will show how to create a PHP site using a basic MVC with Twig templates, saving and retrieving data in DynamoDB, use the POST and GET HTTP methods, the correct way to redirect using PHP on top of a JavaScript shim, store your assets on S3 and CloudFront amongst other neat tricks. Let the fun begin - pick your tutorial from the list below!