Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
frostealth committed Apr 8, 2016
0 parents commit 9cfd068
Show file tree
Hide file tree
Showing 40 changed files with 2,312 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_new_line = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
grumphp.yml export-ignore
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
thumbs.db
*.class
*.pyc
*.pyo
*.swp
.project
.settings
.idea
composer.phar
composer.lock
vendor
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Ivan Kudinov

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.
106 changes: 106 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Yii2 AWS S3

An Amazon S3 component for Yii2.

[![License](https://poser.pugx.org/frostealth/yii2-aws-s3/license)](https://github.com/frostealth/yii2-aws-s3/blob/2.x/LICENSE.md)
[![Latest Stable Version](https://poser.pugx.org/frostealth/yii2-aws-s3/v/stable)](https://packagist.org/packages/frostealth/yii2-aws-s3)
[![Total Downloads](https://poser.pugx.org/frostealth/yii2-aws-s3/downloads)](https://packagist.org/packages/frostealth/yii2-aws-s3)
[![Latest Unstable Version](https://poser.pugx.org/frostealth/yii2-aws-s3/v/unstable)](https://packagist.org/packages/frostealth/yii2-aws-s3)

## Installation

1. Run the [Composer](http://getcomposer.org/download/) command to install the latest stable version:

```bash
composer require frostealth/yii2-aws-s3 ~2.0@stable
```

2. Add the component to `config/main.php`

```php
'components' => [
// ...
's3' => [
'class' => 'frostealth\yii2\aws\s3\Service',
'credentials' => [ // Aws\Credentials\CredentialsInterface|array|callable
'key' => 'my-key',
'secret' => 'my-secret',
],
'region' => 'my-region',
'defaultBucket' => 'my-bucket',
'defaultAcl' => 'public-read',
],
// ...
],
```

## Basic usage

### Usage the command factory and additional params

```php
/** @var \frostealth\yii2\aws\s3\Service $s3 */
$s3 = Yii::$app->get('s3');
/** @var \Aws\ResultInterface $result */
$result = $s3->commands()->get('filename.ext')->saveAs('/path/to/local/file.ext')->execute();
$result = $s3->commands()->put('filename.ext', 'body')->setContentType('text/plain')->execute();
$result = $s3->commands()->delete('filename.ext')->execute();
$result = $s3->commands()->upload('filename.ext', '/path/to/local/file.ext')->setAcl('private')->execute();
$result = $s3->commands()->restore('filename.ext', $days = 7)->execute();
$isExisting = $s3->commands()->exist('filename.ext')->execute();
$url = $s3->commands()->getUrl('filename.ext')->execute();
$signedUrl = $s3->commands()->getPresignedUrl('filename.ext', '+2 days')->execute();
```
### Short syntax
```php
/** @var \frostealth\yii2\aws\s3\Service $s3 */
$s3 = Yii::$app->get('s3');
/** @var \Aws\ResultInterface $result */
$result = $s3->get('filename.ext');
$result = $s3->put('filename.ext', 'body');
$result = $s3->delete('filename.ext');
$result = $s3->upload('filename.ext', '/path/to/local/file.ext');
$result = $s3->restore('filename.ext', $days = 7);
$isExisting = $s3->exist('filename.ext');
$url = $s3->getUrl('filename.ext');
$signedUrl = $s3->getPresignedUrl('filename.ext', '+2 days');
```
### Asynchronous execution
```php
/** @var \frostealth\yii2\aws\s3\Service $s3 */
$s3 = Yii::$app->get('s3');
/** @var \GuzzleHttp\Promise\PromiseInterface $promise */
$promise = $s3->commands()->get('filename.ext')->async()->execute();
$promise = $s3->commands()->put('filename.ext', 'body')->async()->execute();
$promise = $s3->commands()->delete('filename.ext')->async()->execute();
$promise = $s3->commands()->upload('filename.ext', 'source')->async()->execute();
```
## License
Yii2 AWS S3 is licensed under the MIT License.
See the [LICENSE.md](LICENSE.md) file for more information.
36 changes: 36 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "frostealth/yii2-aws-s3",
"type": "yii2-extension",
"description": "An Amazon S3 component for Yii2",
"keywords": ["yii2", "aws", "s3", "aws-s3", "yii2-aws", "yii2-s3"],
"homepage": "https://github.com/frostealth/yii2-aws-s3",
"license": "MIT",
"authors": [
{
"name": "Ivan Kudinov",
"email": "[email protected]",
"homepage": "http://frostealth.ru"
},
{
"name": "Constantine Chuprik",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/frostealth/yii2-aws-s3/issues?state=open"
},
"require": {
"php": ">=7.0.0",
"aws/aws-sdk-php": "~3.17",
"yiisoft/yii2": "~2.0"
},
"require-dev": {
"phpro/grumphp": "~0.8",
"squizlabs/php_codesniffer": "~2.3"
},
"autoload": {
"psr-4": {
"frostealth\\yii2\\aws\\s3\\": "src/"
}
}
}
12 changes: 12 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
parameters:
git_dir: .
bin_dir: ./vendor/bin
tasks:
git_blacklist:
keywords:
- "die("
- "die;"
- "exit("
- "exit;"
- "print_r("
- "var_dump("
Loading

0 comments on commit 9cfd068

Please sign in to comment.