sters / cakephp3-aws-s3-datasource
AWS S3 datasource in CakePHP3
                                    Fund package maintenance!
                                                                            
                                                                                                                                        sters
                                                                                    
                                                                
Installs: 11 618
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 3
Open Issues: 0
Type:cakephp-plugin
pkg:composer/sters/cakephp3-aws-s3-datasource
Requires
- aws/aws-sdk-php: ~3.18
Requires (Dev)
- cakephp/cakephp: ~3.2
- cakephp/cakephp-codesniffer: dev-master
- mockery/mockery: dev-master
- phpunit/phpunit: ~5.6
This package is auto-updated.
Last update: 2025-10-27 18:20:27 UTC
README
This CakePHP 3.0 plugin provides AWS S3 Datasource.
Installation
Install Plugin using composer.
$ composer require "sters/cakephp3-aws-s3-datasource:dev-master"
Add Plugin::load() on your config/bootstrap.php.
Plugin::load('CakeS3');
Add S3 Datasource on your config/app.php.
one Datasrouce has one S3 Bucket connection. You can not across bucket processing.
'Datasource' => [
    'my_s3_connection' => [
        'className'  => 'CakeS3\Datasource\Connection',
        'key'        => 'put your s3 access key',
        'secret'     => 'put your s3 access secret',
        'bucketName' => 'put your bucket name',
        'region'     => 'put your region',
    ],
],
Setup new table using s3 connection.
$_connectionName is your wrote connection name in config/app.php Datasource.
<?php
namespace App\Model\Table;
use CakeS3\Datasource\AwsS3Table;
class MyS3Table extends AwsS3Table
{
    protected static $_connectionName = 'my_s3_connection';
}
For example, declare action of get & show S3 Object.
class TopController extends Controller
{
    public function index()
    {
        $MyS3Table = TableRegistry::get('MyS3');
        $content = $MyS3Table->getObjectBody('/path/to/object/file.jpg');
        $this->response->type('image/jpeg');
        $this->response->body($content);
        return $this->response;
    }
}
Documentation
AwsS3Table support methods
The methods can call on your S3 Table.
If You want more detail, go to S3Client document. http://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.S3.S3Client.html