farhan928 / yii2-aws-s3-client
Yii2 wrapper extension for aws sdk s3 client
Installs: 917
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- aws/aws-sdk-php: ^3.87
This package is auto-updated.
Last update: 2025-05-27 21:48:28 UTC
README
The Yii2 AWS S3Client is a wrapper for AWS S3Client SDK for PHP.
Installation
The preferred way to install this extension is through composer.
Pre-requisites
You must have composer installed on your machine.
Install
Either run
$ composer require farhan928/yii2-aws-s3-client "^1.0.0"
or add
"farhan928/yii2-aws-s3-client": "^1.0.0"
to the require
section of your composer.json
file.
Release Changes
NOTE: Refer the CHANGE LOG for details on changes to various releases.
Usage
Add this code below to your main config and your are ready to go.
// add this in your component section 's3Client' => [ 'class' => 'farhan928\AwsS3\S3Client', 'key' => 'YOUR_AWS_KEY', 'secret' => 'YOUR_AWS_SECRET', 'bucket' => 'YOUR_BUKCET', ],
Examples
Get object URL
Yii::$app->s3Client->url('file.png');
Generate and get temporary URL
Yii::$app->s3Client->temporaryUrl('file.png', 5); //second argument is the duration in minute
Upload raw file contents on bucket
Yii::$app->s3Client->put('file.png', file_get_contents('https://i.imgur.com/hAjCMan.jpg'))
Copy object to new location
Yii::$app->s3Client->copy('old.png', 'file/new.png')
Move object to new location
Yii::$app->s3Client->move('old.png', 'file/new.png')
Get all files from a directory
// get all files Yii::$app->s3Client->files('path/to/your/folder/'); // get certain type of files Yii::$app->s3Client->files('path/to/your/folder/', ['jpg', 'png']);
License
yii2-aws-s3-client is released under the BSD-3-Clause License