If you’re building a small, single-purpose Web application and you want to run it in the cloud, the the typical option is to reach for a small cloud server from Amazon, Google or Azure. Those servers are relatively cheap to run and easy to deploy, but there’s an ongoing investment of time and effort required to keep them secure and updated.
In many cases, a even easier solution is to run your application using a Functions-as-a-Service (FaaS) platform. This is essentially a server-less deployment which hosts your code as a standalone function (or series of inter-connected functions) in the cloud and executes it on demand in response to incoming requests, or at a pre-defined schedule. The key advantage here is there is almost no administrative overhead related to server hosting or maintenance, plus you can easily scale up (or down) the deployment as needed.
I recently had an opportunity to try IBM Cloud Functions, a FaaS platform built on Apache OpenWhisk, and was able to develop a number of purpose-built PHP applications on it. Although it took a few experiments and some time spent reading the documentation, I found that I was able to do almost everything you’d expect to do in a standard hosted PHP environment, including using external PHP libraries, integrating with third-party APIs and external databases, scheduling tasks and accessing detailed debug logs.
If this sounds like something you’d like to try for your next PHP project, take a look at my tutorial on IBM Developer, in which I discuss some common use cases (together with example code). To demonstrate real-world utility, I also walk you through building a full-fledged PHP application that integrates with Slack and OpenWeatherMap to send you automatic weather notifications for your city in your Slack workspace.