Download the PHP package andrewfenn/aws-helper without Composer
On this page you can find all versions of the php package andrewfenn/aws-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrewfenn/aws-helper
More information about andrewfenn/aws-helper
Files in andrewfenn/aws-helper
Package aws-helper
Short Description A small helper library to make intergration of the AWS SDK easier
License MIT
Homepage https://github.com/andrewfenn/awshelper/
Informations about the package aws-helper
AWS Helper
This library is an extension of the AWS SDK to make it easier to intergrate AWS security token service where you refresh the access and secret token via the AWS API on the server itself.
This is better than having a static access and secret key as it constantly changes and only your server on AWS can get access to this information. I have provided a small step by step list below on how to set this up on your AWS account.
It's not meant to be an all inclusive library that can do everything, if you need more advanced use cases then please consider using the AWS SDK directly.
How to install
Add the following to your composer.json file and run .
This library is set up to use amazon's roles for getting the access and secret key. If you don't want to do this then, for example you're developing on your own system outside of AWS then see below.
How to setup your AWS account
If you wish to use amazon's roles so that you're not storing the access or secret key to your services in the code base, do the following.
- Login to your amazon console
- Go to Identity and Access Management
- Click the Roles link
- Create a new role, open it up and click on "attach role policy"
- Select from the policy template for the service you wish to use i.e. "Amazon S3 Full Access", "Amazon SQS Full Access"
- Add the role name you created to the "iam_role" configuration option
Once you've done these steps the key, secret, and security tokens will be downloadable from the a url inside amazon's infrastructure that will provide your server with access.
How to setup for development outside of amazon
For local development make a file like below called development.json
Change the AccessKeyId, and SecretAccessKey fields to your appropiate settings. Make sure the Expiration date is a date in the future or the code will attempt to grab a new key every time you run your code.
I recommend you do not commit the development.json file. This file should sit somewhere secure that only your development team can access as it contains your AWS Access and Secret key details.
Quick use of the S3 Helper
To use the S3 helper library you'll do something similar as below.
A quick note that $file_pointer returns a file pointer instead of the contents of the file as a design choice, as some files may be too big to fit into PHP memory. Please also consider this when using this code so that you don't make mistakes in loading huge files into PHP.
Quick use of the SQS Helper
Included is a small SQS helper library that allows you to clearly setup pushing and recieving from a queue with little hassle.
This helper will refresh the security token if the expiration date has passed so if you have a long running process the code continues to run without throwing an expiration exception.
The aforementioned code will generate the following output.