1. Go to this page and download the library: Download andrewfenn/aws-helper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andrewfenn / aws-helper example snippets
$awsHelper = new AwsHelper('development.json', 'http://url-to-root-folder-with-file/');
use AwsHelper\AwsHelper;
use AwsHelper\S3Helper;
/* instantiate S3 Helper */
$adapter = new S3Helper(new AwsHelper('iam-role'), 'bucket-name');
/* Get a file from S3, store it temporarily on the system */
$file_pointer = $adapter->getFile('some/place/in/the/bucket/foo.txt');
if ($file_pointer === false)
return false;
/* Read the entire file's contents into php */
$files_contents = fread($file_pointer, fstat($file_pointer)['size']);
/* The file downloaded to $file_pointer is destroyed upon script end
if you need to use this file afterwards then you need to copy it out
to somewhere else on the system. */
// Change the URL of your SQS queue in the appropiate field
$adapter = new SqsHelper(new AwsHelper('iam-role'), 'https://sqs.eu-west-1.amazonaws.com/****/queue-name-here');
// Push a message to SQS
$adapter->push('hello');
// The listen() command will block until a message comes in
foreach($adapter->listen() as $message)
{
// Grab the Body of the message
echo $message->get('Body')."\n";
// Delete the message off the queue
$adapter->remove($message);
// Stop the listener thereby exiting the foreach
$adapter->stop();
}
echo "Done\n";
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.