Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Running your Symfony project on AWS Lambda

nealio82
September 28, 2018

Running your Symfony project on AWS Lambda

Given during Symfony Live London 2018, this presentation showcases a new tool called Bref, which takes the pain out of deploying PHP projects on AWS Lambda, allowing you to focus on your application code while saving money by cutting down on wasted server resources.

See https://github.com/mnapoli/bref for more info

nealio82

September 28, 2018
Tweet

More Decks by nealio82

Other Decks in Programming

Transcript

  1. fun

  2. EC2

  3. Lambda is a piece of code that only costs you

    money while it’s being executed
  4. • Well documented • Serverless framework plugin (easy to get

    running) • Built on top of FIG standards (PSR-7) mnapoli/bref
  5. • Setting up a new ‘Hello World’ SF 4 site

    • Setting up a REST API with database migrations • Converting an existing site to Lambda • Retro-fitting to an older Symfony site • Cron tasks • Performance
  6. • Install Symfony • Install Bref • Set up some

    config • Deploy • Explore the environment • Fix any issues
  7. • Installed Symfony • Installed Bref • Copied config from

    the docs • Deployed • Had a look around • Used Cloudwatch to help us debug
  8. • Install Api-Platform • Install Bref • Add a database

    connection • Run Symfony commands • Get rid of the ugly Cloudfront hostname
  9. • Change logs directory in Kernel class • Configure includes

    in serverless.yml • Replace contents of bref.php with Symfony adapter • Add cache warmup to .bref.yml
  10. • Installed Symfony • Installed Api-Platform • Installed Bref •

    Configured the standard files • Added a database connection through environment vars • Ran Symfony commands • Added a custom domain name via the AWS GUI
  11. • Install Bref to an existing site • Move assets

    to a CDN • Move session storage to a centralised location • Add image uploading
  12. • Change logs directory in Kernel class • Configure includes

    in serverless.yml • Replace contents of bref.php with Symfony adapter • Add cache warmup to .bref.yml
  13. Lambda function JS Handler PHP Binary PSR-7 API Gateway Data

    Store JS Handler PHP Binary PSR-7 Sessions Sessions
  14. Lambda function JS Handler PHP Binary PSR-7 API Gateway Data

    Store JS Handler PHP Binary PSR-7 Sessions
  15. Client Server Amazon S3 Get Pre-Signed URL Get Pre-Signed URL

    One-time use URL One-time use URL PUT file to One-time use URL 200 OK
  16. Client Server Amazon S3 Get Pre-Signed URL Get Pre-Signed URL

    One-time use URL One-time use URL PUT file to One-time use URL 200 OK Update record
  17. Client Server Amazon S3 Get Pre-Signed URL Get Pre-Signed URL

    One-time use URL One-time use URL PUT file to One-time use URL 200 OK Update record Delete previous file
  18. • Added Bref to an existing site • Fixed assets

    by moving them to a CDN • Added serverless-s3-uploads plugin • Configured CORS & bucket security in serverless.yml • Moved session storage to the database • Used pre-signed URLs for image uploading
  19. • Setting up a new ‘Hello World’ SF 4 site

    • Setting up an Api-Platform site with database migrations • Converting an existing site to Lambda • Retro-fitting to an older Symfony site • Cron tasks • Performance