Skip to content
This is the documentation for pieceofcake2/aws, a CakePHP 2.x plugin for pieceofcake2/cakephp. About this fork.

AWS Documentation ​

The AWS plugin integrates the AWS SDK for PHP with CakePHP 2 applications running on pieceofcake2/cakephp. It provides an Aws component that creates AWS service clients, an S3 stream wrapper (s3:// paths), a session handler and a cache engine that store data in Amazon DynamoDB, and an email transport that sends email with the Amazon SES API v2.

A lighter alternative based on AsyncAws is pieceofcake2/async-aws. It provides the same features and installs only the AWS services you use, which keeps deployments small, for example on AWS Lambda. See Migrating from pieceofcake2/aws.

Installation ​

Install the plugin with Composer:

bash
composer require pieceofcake2/aws

The plugin has the cakephp-plugin type, so it is installed into your plugins directory by composer/installers. Set installer-paths in your application's composer.json so it is installed into the right place:

Layoutinstaller-paths
Modern (config/, src/, templates/, plugins/)"plugins/{$name}/": ["type:cakephp-plugin"]
Legacy (app/Config/, app/Plugin/)"app/Plugin/{$name}/": ["type:cakephp-plugin"]

Load the plugin in config/bootstrap.php (legacy layout: app/Config/bootstrap.php). If you already use CakePlugin::loadAll(), this is not necessary:

php
CakePlugin::load('Aws');

To also register the S3 stream wrapper and the Amazon SES mailer DSNs, load the plugin with its bootstrap:

php
CakePlugin::load('Aws', ['bootstrap' => true]);

AWS Configuration ​

All clients are created from the Aws configuration, which is passed to Aws\Sdk as the shared configuration of the SDK. Set it in config/core.php (legacy layout: app/Config/core.php), or in config/bootstrap.php before the plugin is loaded:

php
Configure::write('Aws', [
    'region' => 'ap-northeast-1',
    'version' => 'latest',
]);

When no credentials are configured, the SDK uses its default credential provider chain: environment variables, the shared credentials file, and the IAM role of the EC2 instance, ECS task or Lambda function. Any other client option of the SDK, such as credentials or endpoint, can be added to this array.

Origin ​

This package was created by pieceofcake2, which also maintains it. It is not a fork of another project and is not based on one.

See LICENSE for copyright and license information. Not affiliated with the Cake Software Foundation.