定制 hotel-quickly/aws-proxy 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hotel-quickly/aws-proxy

Composer 安装命令:

composer require hotel-quickly/aws-proxy

包简介

Proxy for AWS PHP library

README 文档

README

Library with proxy classes for AWS SDK PHP library.

For documentation of AWS SDK PHP library see documentation.

Implemented proxies for services

  • S3 storage service
  • DynamoDB
  • SQS queue

Usage

S3 Storage service

$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);

DynamoDB

Proxy automatically converts php arrays to format required by DynamoDB

$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'
	));

Proxy supports primary key consisting with multiple values.

For update, you need to provide array of values for primary key

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

SQS queue management

$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'
	));

The MIT License (MIT)

Copyright (c) 2014 Hotel Quickly Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

统计信息

  • 总下载量: 45.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 32
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固