I never really got the point of “serverless.” It seems kinda no-duh, like someone inventing another kind of wheel. I’ve spent the last couple of days dabbling with it. And now I get it, it’s PHP-FPM for other languages.
See, us PHP developers have basically had “serverless” for quite some time. PHP-FPM is what we used for years (decades?). Basically we’ve written little functions that only load what they need and execution even has to “warm up” just like serverless (aka, the opcache).
The biggest difference between PHP-FPM and serverless is with PHP-FPM, you need to set it up and run a server. There’s currently no serverless architecture that natively runs PHP (except maybe, Azure, with a few tweaks).
Why Someone Needs to Run Serverless PHP Natively
A ridiculously large portion of the internet already runs PHP. If I could host my PHP application/API in a serverless architecture, a ton of my personal “play money” could be spent on better things.
At the same time, this is suicide for all hosting companies that currently host all websites. Suddenly, no one would need servers. PHP would be, quite literally, the easiest migration to serverless known to mankind.
Someone should build a way (using the existing known hacks) to migrate a WordPress install to one of the serverless platforms to execute as though it’s running on a native server. There’s currently hacks to convert WordPress sites to static html (but that’s just a marketing gimmick — nginx + PHP-FPM has that built in and is currently what you’re reading now). I’m talking about a real WordPress install, running PHP with some kind of cache in-place on the API gateway.
3 responses to “Serverless: From a PHP Developer’s Experience”
Actually, you can make PHP work with AWS Lamda. Look into Lambda Layers and setting up custom runtimes if you’re curious. Launched at 2018 re:invent. It was possible before, but this should make it a bit more accessible. Although, it’s still not as straightforward as other NodeJS for example.
Great little article. I agree with most of the idea. My personal side project that is consuming me is what I call “getting WordPress out of WordPress” it makes all the front-end and templating server message and keeps the admin side in a small light sail instance. It’s been fun and helps move all the client facing pieces into a server message setup and doesnt take any more understanding then WordPress takes to publish.
Static HTML conversion is more than a marketing gimmick – you can convert it, upload it to S3, and turn off your server. Just start it up for making changes 🙂