PHP AWS

Let’s start by splicing the abbreviations, PHP was originally known as Personal Home Page way back in 1995 but is now known as Hypertext Preprocessor. PHP is basically a server side scripting language specifically designed for web application development but works just as well for general purpose programming. AWS, on the flip side is the Amazon Web Services platform.

Just for the sake of simplicity, let’s just delve a little deeper, the “server-side scripting” uses a set of readymade scripts or code on the server side which produces a “response” or “reply”. The “response”, is customized for every “user or client” requests that is made to the website. When brought together in marriage, PHP-AWS is a library of pre-written PHP classes designed to access Amazon’s web services (AWS) platform.

Here’s the boiled down version, it is essentially the elegance of bringing two libraries together and drastically reducing your source lines of code (SLOC). Here’s an analogy, imagine a chef writing two separate books on Italian food, the first book only consisting of the ingredients and the latter containing the method of cooking the dish. You are probably thinking, pointless or long winded exercise, right? However, bring the both books together with the ingredients at the top and how to cook at the bottom, PHP is the “ingredient” and AWS is the “method” to effect the job seamlessly.

Now, you are probably wondering why PHP and not any other scripting language? It’s purely due to its simplicity, speed, stability and enormous popularity. Wikipedia, Facebook, Yahoo, WordPress and Twitter are amongst some of its most renowned users. At present, PHP supports Amazon’s Simple Storage Service (S3), Simple Queue Service (SQS), Dynamo DB, Glacier, Elastic Compute Cloud (EC2) and Alexa Web Information Service (AWIS). In today’s pressurising work environments, you will be pleased to learn that developers can literally start the ground sprinting in minutes like Usain Bolt by just installing AWS SDK for PHP via Composer or opting for the traditional standalone zip folders.

Real Life Example
Okay, let’s just take an Amazon Simple Queue Service (SQS) which is basically a messaging queue service that has the ability to handle message or workflows between other concurrent components within the system. So, firstly you need to create a client “object” by using this technique within the Aws\Sqs\SqsClient::factory() method and that will provide your credential profile which stipulates and identifies the set of credentials you are looking from the AWS Credentials file.

You will then obviously need a “region” parameter, and you can use an existing list of available regions by selecting the Regions and Endpoints reference and here it is in all its glory:-


use Aws\Sqs\SqsClient;
$client = SqsClient::factory(array(
'profile' => '<profile in="in" your="your" aws="aws" credentials="credentials" file="file">',
'region' => '<region name="name">'
));

The AWS SDK for PHP Version 3 contains many savoury goodies such as asynchronous requests, command pools, result querying with JMESPath, response paginators, streamlined extension architecture and a few performance improvements.