PHPackages                             bahirul/yii2-simple-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. bahirul/yii2-simple-s3

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

bahirul/yii2-simple-s3
======================

Simple Yii2 extension for custom S3 filesystem

0.0.2(6y ago)03MITPHP

Since Apr 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bahirul/yii2-simple-s3)[ Packagist](https://packagist.org/packages/bahirul/yii2-simple-s3)[ RSS](/packages/bahirul-yii2-simple-s3/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Simple Custom S3 for Yii2
=========================

[](#simple-custom-s3-for-yii2)

Simple extension for custom S3 filesystem with basic functionality : read, write, delete.
This extension use [Flysystem](http://flysystem.thephpleague.com/) as core filesystem.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require bahirul/yii2-simple-s3
```

or add

```
"bahirul/yii2-simple-s3": "^0.0.2"

```

to the `require` section of your `composer.json` file.

Configuring
-----------

[](#configuring)

Configure application `components` as follows

```
return [
    //...
    'components' => [
        //...
        's3' => [
            'class' => 'bahirul\yii2\SimpleS3',
            'endpoint' => 'YOUR_S3_URL',
            'key'    => 'YOUR_S3_KEY',
            'secret' => 'YOUR_S3_SECRET',
            'bucket' => 'YOUR_S3_BUCKET',
            //'region' => 'YOUR_S3_REGION', // Optional
            //'version' => 'YOUR_S3_VERSION', // Optional
        ],
    ],
];
```

Usage
-----

[](#usage)

### Read file from S3

[](#read-file-from-s3)

`readFile()` method will return array with key 'stream' and 'mimetype'.

send as response in controller

```
// s3 custom init
$s3 = Yii::$app->s3;

// your requested file
$fileRequest = 'example_file_image.jpg';

// read file on S3
$readFile = $s3->readFile($fileRequest);

// init web response
$response = Yii::$app->response;
$response->headers->set('Content-Type', $readFile['mimetype']);
$response->format = \yii\web\Response::FORMAT_RAW;
$response->stream = $readFile['stream'];

return $response->send();
```

or send as file in controller

```
// s3 custom init
$s3 = Yii::$app->s3;

// your requested file
$fileRequest = 'example_file_image.jpg';

// read file on S3
$readFile = $s3->readFile($fileRequest);

// init web response
$response = Yii::$app->response;

return $response->sendStreamAsFile($readFile['stream'], $fileRequest ,['mimeType' => $readFile['mimetype']]);
```

### Write file to S3

[](#write-file-to-s3)

`writeFile()` method will return boolean.

write (upload) usage on controller

```
// your file upload instance
$fileModel = UploadedFile::getInstance($model, 'attributeName');

$s3 = Yii::$app->s3;

// generate random filename
$filename = time() . '.jpg';

if($model->load($post) && $model->validate()){
    // upload file to s3
    $s3->writeFile($fileModel, $filename);
}
```

### Delete file on S3

[](#delete-file-on-s3)

`deleteFile()` method will return boolean.

delete usage on controller

```
$s3 = Yii::$app->s3;

$fileRequest = 'example_file_image.jpg';

$s3->deleteFile($fileRequest);
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

Every ~2 days

Total

2

Last Release

2200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/96498e0a3371c1580b9ed83580d8afa3a62ec565fc9329a9a6f25335135c3ea8?d=identicon)[bahirul](/maintainers/bahirul)

---

Top Contributors

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

---

Tags

s3-buckets3-storageyii2-extension

### Embed Badge

![Health badge](/badges/bahirul-yii2-simple-s3/health.svg)

```
[![Health](https://phpackages.com/badges/bahirul-yii2-simple-s3/health.svg)](https://phpackages.com/packages/bahirul-yii2-simple-s3)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[jerodev/flysystem-v3-smb-adapter

SMB adapter for Flysystem v3

1289.9k1](/packages/jerodev-flysystem-v3-smb-adapter)

PHPackages © 2026

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