Server less is a Great Concept. In our previously published articles, we discussed about IBM OpenWhisk and also shown how to install OpenWhisk on Ubuntu server. As it is a Free Software framework, we have no fear of vendor lock-in if we carefully use the PHP functions only. Here is Introduction to Serverless With PHP For IBM Cloud OpenWhisk.
Serverless concept itself as basic as using some object storage to host HTML, CSS, Javascript to do intended action. That is nothing new. We need kind-of-same to execute PHP like dynamic langugage on others server/service than on our hosting server. That will offload the load on server and hopefully make kind-of “parallel processing” because webpage’s HTTP call and call via CLI are different events – that makes a big difference with Javascript. It is like as if a ghost running PHP CLI commands from our servers on others server and delivering the result. We talked about Function-as-a-Service (FaaS). The ideas are great but examples, documentations for genuine deployment like as WordPress plugin is almost non-existent.
Fortunately or unfortunately, you may need to setup your computer with IBM Bluemix Tools. These setups on own server is single most disgusting work when compared with IaaS/Cloud Server. Even if not needed for OpenWhisk, you’ll need them some other tool.
---
Serverless is a Node.js CLI tool. Go to the official Node.js website, download and follow the installation instructions :
1 | https://serverless.com/framework/docs/providers/openwhisk/guide/installation/ |
With OpenWhisk we can extract computing power from our lesser used server from popular one apart from using it as service of IBM or others. So, your two extra few GB RAM servers actually not going in waste.
Introduction to Serverless With PHP
Thankfully there is PHP Composer package for OpenWhisk. Oddly, IBM has another Composer with conflicting name :
1 | https://github.com/ibm-functions/composer |
We were taling about this Composer :
1 | https://dzone.com/articles/using-composer-packages-with-openwhisk |
OpenWhisk has Actions, which is PHP Functions. Sequences is to connect and chain multiple actions.
Triggers are for organizing event sources. Rules connect Triggers and Actions. Packages allows to bundle a set of actions.
Serverless has own website :
1 | https://serverless.com/ |
As Amazon, IBM and native Apache OpenWhisk are working for the same stuff, it will be prudent to install Apache OpenWhisk on own server and test, deploy the stuffs. It is not practical to develop, code for IBM or Amazon, rather adjust coding on need. You’ll get Example for IBM on that website :
1 | https://serverless.com/framework/docs/providers/openwhisk/examples/ |
Then you can test this :
1 | https://github.com/serverless/examples/tree/master/openwhisk-php-simple |
You can read this guide :
1 | http://blog.zerosharp.com/a-concrete-php-serverless-example/ |
Some PHP frameworks for OpenWhisk developed, each has own merit. Usage for Amazon service may differ :
1 | https://read.acloud.guru/serverless-php-630bb3e950f5 |
You may create a Hello Dolly Plugin for WordPress using OpenWhisK to test. I am at Hello Dolly stage around OpenWhisk.