Posts tagged aws

Simple framework wrapper for Amazon’s AWS SDK for PHP 5

If you interact with any of Amazon’s Web Services using PHP you should be using their SDK.

It’s very powerful and pretty simple to get started with.

In my case I did not want to checkout their whole repository into my frameworks namespace and decided to use .phar file they provided as
an alternative.

To me, using a .phar file for third party libraries kind of makes sense if I’m not planning to extend or overwrite any of the available functionality.

Plus if you have your own directory conventions and don’t want to bother re-factoring Amazon’s structure, .phar might come in handy.

The issue I ran into (not really an issue but inconsistency always bothers me as an engineer) is that if you are using namespaces and your own autoloader, requiring .phar file anywhere you need to access AWS is pretty ghetto.

The way I solved it is by using a very simple wrapper that either loads configuration (using \library\configuration as an example) containing your key/secret or takes key/secret as a constructor parameter and simply stores instance of AWS internally while routing all the calls directly to it.

You can check out this approach on my GitHub page located here: https://github.com/AlekseyKorzun/aws-sdk-wrapper