PHPackages                             byarashboev/yii1-aws-s3 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. byarashboev/yii1-aws-s3

ActiveLibrary[File &amp; Storage](/categories/file-storage)

byarashboev/yii1-aws-s3
=======================

Amazon S3 or Amazon Simple Storage Service component for Yii1

1.0.0(4mo ago)02MITPHPPHP &gt;=7.3

Since Feb 20Pushed 4mo agoCompare

[ Source](https://github.com/byarashboev/yii1-aws-s3)[ Packagist](https://packagist.org/packages/byarashboev/yii1-aws-s3)[ RSS](/packages/byarashboev-yii1-aws-s3/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Yii1 AWS S3
===========

[](#yii1-aws-s3)

Amazon S3 or Amazon Simple Storage Service component for Yii1.

Installation
------------

[](#installation)

Install via [Composer](https://getcomposer.org):

```
composer require byarashboev/yii1-aws-s3 "^1.0"
```

Dependencies
------------

[](#dependencies)

- PHP 7.3+
- [yiisoft/yii](https://github.com/yiisoft/yii) ~1.1
- [aws/aws-sdk-php](https://github.com/aws/aws-sdk-php) ~3.337.0

Configuration
-------------

[](#configuration)

Add the component to your `config/main.php`:

```
'components' => [
    // ...
    's3' => [
        'class' => 'byarashboev\aws\s3\Service',
        'endpoint' => 'my-endpoint',
        'usePathStyleEndpoint' => true,
        'credentials' => [
            'key' => 'my-key',
            'secret' => 'my-secret',
        ],
        'region' => 'my-region',
        'defaultBucket' => 'my-bucket',
        'defaultAcl' => 'public-read',
    ],
    // ...
],
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
/** @var \byarashboev\aws\s3\Service $s3 */
$s3 = Yii::app()->getComponent('s3');
// or
$s3 = Yii::app()->s3;

// Usage of the command factory and additional params
// ==================================================

/** @var \Aws\ResultInterface $result */
$result = $s3->commands()->get('filename.ext')->saveAs('/path/to/local/file.ext')->execute();

$result = $s3->commands()->put('filename.ext', 'body')->withContentType('text/plain')->execute();

$result = $s3->commands()->delete('filename.ext')->execute();

$result = $s3->commands()->upload('filename.ext', '/path/to/local/file.ext')->withAcl('private')->execute();

$result = $s3->commands()->restore('filename.ext', $days = 7)->execute();

$result = $s3->commands()->list('path/')->execute();

/** @var bool $exist */
$exist = $s3->commands()->exist('filename.ext')->execute();

/** @var string $url */
$url = $s3->commands()->getUrl('filename.ext')->execute();

/** @var string $signedUrl */
$signedUrl = $s3->commands()->getPresignedUrl('filename.ext', '+2 days')->execute();

// Short syntax
// ============

/** @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);

$result = $s3->list('path/');

/** @var bool $exist */
$exist = $s3->exist('filename.ext');

/** @var string $url */
$url = $s3->getUrl('filename.ext');

/** @var string $signedUrl */
$signedUrl = $s3->getPresignedUrl('filename.ext', '+2 days');

// Asynchronous execution
// ======================

/** @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();

$promise = $s3->commands()->list('path/')->async()->execute();
```

### Advanced Usage

[](#advanced-usage)

```
/** @var \byarashboev\aws\s3\Service $s3 */
$s3 = Yii::app()->s3;

/** @var \byarashboev\aws\s3\commands\GetCommand $command */
$command = $s3->create(GetCommand::class);
$command->inBucket('my-another-bucket')->byFilename('filename.ext')->saveAs('/path/to/local/file.ext');

/** @var \Aws\ResultInterface $result */
$result = $s3->execute($command);

// or async
/** @var \GuzzleHttp\Promise\PromiseInterface $promise */
$promise = $s3->execute($command->async());
```

Using Traits
------------

[](#using-traits)

### Model Trait

[](#model-trait)

Attach the Trait to your `CActiveRecord` model:

```
/**
 * @property string|null $image
 */
class MyModel extends CActiveRecord
{
    use \byarashboev\aws\s3\traits\ModelTrait;

    public function rules()
    {
        return [
            ['image', 'length', 'max' => 255],
        ];
    }

    protected function attributePaths()
    {
        return [
            'image' => 'images/'
        ];
    }
}
```

#### Using Trait Methods

[](#using-trait-methods)

```
$image = CUploadedFile::getInstance($model, 'image');

// Save to S3, auto-detect extension
$model->saveUploadedFile($image, 'image', 'image_thumb');

// Save with forced extension
$model->saveUploadedFile($image, 'image', 'image_thumb.png', false);

// Get the URL
$model->getFileUrl('image');

// Get presigned URL (default: +5 minutes)
$model->getFilePresignedUrl('image');

// Remove file from S3
$model->removeFile('image');
```

#### Overriding Trait Methods

[](#overriding-trait-methods)

##### getS3Component

[](#gets3component)

```
public function getS3Component()
{
    return Yii::app()->getComponent('my_s3_component');
}
```

##### attributePaths

[](#attributepaths)

```
protected function attributePaths()
{
    return [
        'logo'  => 'logos/',
        'badge' => 'images/badges/',
    ];
}

// or with dynamic paths
protected function attributePaths()
{
    return [
        'logo'  => 'thumbnail/' . $this->id . '/logos/',
        'badge' => 'thumbnail/' . $this->id . '/images/badges/',
    ];
}
```

##### getPresignedUrlDuration

[](#getpresignedurlduration)

```
protected function getPresignedUrlDuration($attribute)
{
    return '+2 Hours';
}
```

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance75

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

134d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a16cccd6c9062a340f8886df1d9e099c961b97c4da81358c49d5a7991b1f513?d=identicon)[BoXoSh](/maintainers/BoXoSh)

---

Top Contributors

[![byarashboev](https://avatars.githubusercontent.com/u/23693354?v=4)](https://github.com/byarashboev "byarashboev (4 commits)")

---

Tags

s3awsextensionyiicomponentYii1aws-s3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/byarashboev-yii1-aws-s3/health.svg)

```
[![Health](https://phpackages.com/badges/byarashboev-yii1-aws-s3/health.svg)](https://phpackages.com/packages/byarashboev-yii1-aws-s3)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[vinelab/cdn

Content Delivery Network (CDN) Package for Laravel

217244.0k1](/packages/vinelab-cdn)[publiux/laravelcdn

Content Delivery Network (CDN) Package for Laravel

157234.9k](/packages/publiux-laravelcdn)[fedemotta/yii2-aws-sdk

This extension provides the AWS SDK integration for the Yii2 framework

15448.9k2](/packages/fedemotta-yii2-aws-sdk)[kolay/xlsx-stream

Streaming XLSX reader and writer for PHP and Laravel. Constant memory regardless of file size, direct S3 multipart streaming, optional born-indexed random access.

437.9k](/packages/kolay-xlsx-stream)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
