Laravel Vapor. Migrating existing app to serverless. Easy or not?

Ivan Kolodii
5 min readMar 14, 2021
Laravel vapor

App autoscaling is not a trivial task as it might look. I was really excited when I read about Vapor. I would like to share my experience of playing with this great tool.

Project size

Our project is nearly 650Mb and Lambda has limitations of 250Mb unzipped.

We had a few binaries in our composer dependencies. I tried to remove them but it doesn’t help.

Want to read this story later? Save it in Journal.

Also removed all dev dependencies. Make sure that you don’t use any PHPUnit functions in your code. For example: assert() etc.

Next, I found out that vapor supports Lambda layers via docker. It has a limit of up to 10Gb per layer.

That helped. All your need to do is only add this line:

runtime: docker

And create a docker file associated with it. You can use the command

vapor env my-environment — docker

Building assets

We use docker containers for the local development and a simple composer install command won’t work locally.

You have to run a command via docker-compose exec.

--

--