PHP code example of hotel-quickly / aws-proxy

1. Go to this page and download the library: Download hotel-quickly/aws-proxy 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/ */

    

hotel-quickly / aws-proxy example snippets


$config = array(
  accessKeyId => xxx,
  secretAccessKeyId => xxx,
  region => 'ap-southeast-1',
  bucket => 'test-bucket' // you can modify later by calling $s3Client->setBucket('another-bucket')
);

$s3Client = new \HQ\Aws\S3Proxy($config);

// $s3FilePath is in format {bucket-name}/{item-key}
$s3Client->downloadFile($s3FilePath, $localFilePath);

// optional 3rd parameter declaring if file should be publicaly accessible (default is false)
// optional 4rd parameter declaring if file should be rewriten when exists on s3 (default is false)
$s3Client->uploadFile($sourcePath, $s3FilePath, true, false);

// determines if given file exists in s3 storage
$s3Client->isFile($s3FilePath);


$s3Client->copyFile($origFilePath, $targetFilePath, true);
$s3Client->moveFile($origFilePath, $targetFilePath);

// returns all files within specified bucket
// optional $prefix parameter specifies path for search
$s3Client->getFiles('/exceptions/');

// saves all files to specified directory
// optional second $prefix parameter to specify path in s3 storage
$s3Client->downloadAllFiles($localDirectoryPath);


$s3Client->deleteFile($filePath);

// return publicly accessible URL for given object
// optional second parameter specify how long should be URL valid
$s3Client->getObjectUrl($key);

// return whole s3 object
// optional second parameter for configuration
$s3Client->getObject($key);

$config = array(
  accessKeyId => xxx,
  secretAccessKeyId => xxx,
  region => 'ap-southeast-1'
);

$dynamoDbClient = new \HQ\Aws\DynamoDbProxy($config);

// insert data
$this->dynamoDbProxy->setTableName('tableName')
	->insert(array(
		'id' => 23,
		'name' => 'Test name',
		'purpose' => 'To show how'
	));

// update data
$this->dynamoDbProxy
	->setTableName('tableName')
	->update(array('id' => 23), array(
		'name' => 'Correct name',
		'description' => 'New description'
	));


$this->dynamoDbProxy
	->setTableName('tableName')
	->update(array(
		'id' => 23,
		'secondaryKey' => 'secondaryValue'
	), array(
		'name' => 'Correct name',
		'description' => 'New description'
	));


$config = array(
  accessKeyId => xxx,
  secretAccessKeyId => xxx,
  region => 'ap-southeast-1'
);

$sqsClient = new \HQ\Aws\SqsProxy($config);

// insert data
$this->sqsClient->setQeueuUrl('xxx')
	->insert(array(
		'id' => 23,
		'name' => 'Test name',
		'purpose' => 'To show how'
	));