18.12. Cloud2Go Services for your web development
Cloud technologies and services increase every day. Global players like Amazon put continuously new features to their cloud and products to provide sufficiently functionality of actually web development activities and requirements.
Services for us
In fact, Amazon starts with the S3 (Simple Storages Service) to provide cloud storage space since 2006 and only a few months later EC2 (Elastic Compute Cloud) was launched a service to provide computing power to manage capacity as many as we need over time. Now, RDS (Relational Database Service) is available to get elastic database power as much as we need to cover all components that we require to implement the whole stack of current web applications.
Use that services to transform the development and of course every application in a liquid and full dynamic status. Every service increase productivity and can be used to cover architecture requirements in sufficient way. That means, use every service as long as we need and allocate capacity as many as we need in the finest way up to 100% not more, not less to reduce resources and costs.
Swim a little bit around
Ok let us start to introduce each important service below to get more details and show examples what we have to do to use these services. Amazon provides a SDK especially for PHP developers to connect each service. You can download the SDK under the following URL:
To start, download and install the SDK to your destination directory in your application root folder. Before we can start edit the configuration file and change the privacy settings with your AWS (Amazon Web Services) credentials (see Listing 1). To get credentials please create an AWS account on:
http://aws.amazon.com/de/ and follow the instructions.
Store data in S3 and handle it similar to our local storages
S3 is the storages service from Amazon where we can store (Create), retrieve (Read), overwrite (Update) and remove (Delete) data. The logical structure based on buckets that contains items like files e.g. images, videos or documents or any data that we want to store. Buckets must have a unique developer-assigned key across the account each item can be contain 1 byte up to 5 terabytes.
Create our bucket
First, to store our objects we create a bucket with the method create_bucket. All what we have to do is specify a name of the bucket A"testbucketA" and the region where we want to create it. In our case the region is A"EU_E1A" (European 1- Region). Additionally, a simple A"if checkA" covers the return value whether the call was correct.
Store our private data
In the next step, we put files to the bucket and store some data to the cloud. Simply, call the create_object method to handle our request.
Listing 3 shows the PHP snippet to create a test file. Call the method with the bucket name A"testbucketA", name of the file A"testfile.txtA" and some additional parameters in our case A"bodyA", A"aclA" and A"contentTypeA" to specify the characteristic of our data.
Get data from the cloud storage
Now we want to get back our stored data. To finalize that request we have to use the method get_object.
Listing 5 covers our example and echoed the string that we have inserted a few minutes before.
To see it is very simple to communicate to our cloud storage with the SDK and execute the proper methods. If you do not know the right method take a look in the library service file where every single method is described well that enclose every required parameter and excepted return values.
Truncated by Planet PHP, read more at the original (another 6648 bytes)