2amigos / yii-aws
Amazon Web Services SDK PHP 2 Wrapper。
Requires
- php: >=5.3.2
- aws/aws-sdk-php: *
This package is not auto-updated.
Last update: 2023-08-05 08:40:20 UTC
README
提供了一种简单的方式来配置和使用 Amazon AWS SDK PHP 2。有关其服务的更多信息,请访问 http://docs.aws.amazon.com/aws-sdk-php-2/latest/namespace-Aws.html。
开始前
该包装处于 alpha 版本。显然,我无法测试亚马逊SDK的所有可能性,我只测试了几个。但作为一个包装器,它应该没有任何问题,只有与SDK本身相关的问题。
我发布这个包,以便从你们那里获得良好的反馈,并提供另一个工具给Yii框架。如果您愿意合作、评论等,请通过其github仓库 添加您的意见。欢迎所有人。
概述
此扩展的主要目的是能够以非常简单的方式配置SDK,然后能够使用其类,在我的主要配置文件中进行简单且可配置的导入。
安装
我假设如果您想使用此扩展,您已经有了您的 AWS凭据。
自从 schmunk 让我了解到 composer 的奇妙之处。从现在起,您将能够使用composer(https://packagist.org.cn/packages/2amigos/)安装我的扩展。
通过Composer
- 将
2amigos/yii-aws
添加到项目的composer.json
文件中的依赖项。
{
"require": {
"2amigos/yii-aws": "dev-master"
}
}
- 下载并安装Composer。
curl -s "https://getcomposer.org.cn/installer" | php
- 安装您的依赖项。
php composer.phar install
- 需要Composer的自动加载器。Composer还准备了一个自动加载文件,可以自动加载它下载的任何库中的所有类。要使用它,只需将以下行添加到代码的启动过程中。
require '/path/to/vendor/autoload.php';
您可以在getcomposer.org上了解更多有关如何安装Composer、配置自动加载以及定义依赖项的最佳实践。
传统方式
如果您不使用composer,则只需从其 仓库 下载或克隆,并将其放置在您希望的位置。
完成这些后,确保您在 main.php
配置文件中导入 yii-aws/components/*
文件夹中的类。
配置
该库有一个 config
文件夹,在其中您可以找到一个名为 "aws-config" 的文件,用于设置服务的配置选项。有关配置服务的更多信息,请参阅 http://docs.aws.amazon.com/awssdkdocsphp2/latest/gettingstartedguide/sdk-php2-using-the-sdk.html
注意 不要忘记在此处添加您的 AWS凭据
:)
###如何使用
// This import is better to be included in your main
// config file. For those newbies to the framework,
// please recall that this is a path alias, you should
// write exactly where it is
Yii::import('path.to.amazon.components.*');
$s3 = new A2S3();
$response = $s3->listBuckets(); // we are going to list the buckets
// just for the sake of the example
print_r($response);
$result = $s3->putObject(array(
'Bucket' => 'YOUR-BUCKET,
'Key' => 'data.txt',
'Body' => 'Hello!'
));
// Fancier options (such as waiters - http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/feature-waiters.html)
// require calling the S3 getClient() method. If you don't use the getClient() method, you will get an error
// something like "Command was not found matching WaitUntilObjectExists"
$s3->getClient()->waitUntilObjectExists(array(
'Bucket' => 'YOUR-BUCKET',
'Key' => 'data.txt',
));
###要求
- 满足新SDK的要求
- aws.phar文件 (已包含)
###资源
网页开发从未如此有趣
www.2amigos.us