PHPackages                             cinghie/yii2-aws - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cinghie/yii2-aws

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

cinghie/yii2-aws
================

Yii2 Amazon Web Services (AWS)

0.1.1(7y ago)03971BSD-3-ClausePHP

Since Apr 10Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/cinghie/yii2-aws)[ Packagist](https://packagist.org/packages/cinghie/yii2-aws)[ Docs](https://github.com/cinghie/yii2-aws)[ RSS](/packages/cinghie-yii2-aws/feed)WikiDiscussions master Synced 6d ago

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

Yii2 AWS
========

[](#yii2-aws)

[![License](https://camo.githubusercontent.com/1609f960ef92085898f1c0beeb011e4d8db044e053c1dca01e312e6d9b980eaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63696e676869652f796969322d6177732e737667)](https://camo.githubusercontent.com/1609f960ef92085898f1c0beeb011e4d8db044e053c1dca01e312e6d9b980eaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63696e676869652f796969322d6177732e737667)[![Latest Stable Version](https://camo.githubusercontent.com/65cd02c3d70999235e9d79c3bf199e2fe6532de3d0a9a444ba84299bc14e8932/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f63696e676869652f796969322d6177732e737667)](https://camo.githubusercontent.com/65cd02c3d70999235e9d79c3bf199e2fe6532de3d0a9a444ba84299bc14e8932/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f63696e676869652f796969322d6177732e737667)[![Latest Release Date](https://camo.githubusercontent.com/f017dddd74177fd561b20ed81080707cb8fcd7ef35013a9e89f476aecbaebb37/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f63696e676869652f796969322d6177732e737667)](https://camo.githubusercontent.com/f017dddd74177fd561b20ed81080707cb8fcd7ef35013a9e89f476aecbaebb37/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f63696e676869652f796969322d6177732e737667)[![Latest Commit](https://camo.githubusercontent.com/4f60d24b1a9e07c92c2c4fbd7635cbfe6b6701fea2acbf9e8752b24e78031e10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f63696e676869652f796969322d6177732e737667)](https://camo.githubusercontent.com/4f60d24b1a9e07c92c2c4fbd7635cbfe6b6701fea2acbf9e8752b24e78031e10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f63696e676869652f796969322d6177732e737667)[![Total Downloads](https://camo.githubusercontent.com/e15dbce34f4ac6cf1b780bd0f04afee8ef645f5bb31ed226c54c84e478beb0ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63696e676869652f796969322d6177732e737667)](https://packagist.org/packages/cinghie/yii2-aws)

Yii2 AWS integrates AWS SDK for PHP v3 into Yii2 applications and provides wrappers for:

- Amazon S3
- Amazon SES
- Amazon SNS
- Yii2 admin dashboards for the included services

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

[](#installation)

```
composer require cinghie/yii2-aws
```

Or add the package to `composer.json`:

```
{
    "require": {
        "cinghie/yii2-aws": "*"
    }
}
```

Basic Configuration
-------------------

[](#basic-configuration)

Configure the `aws` component and, if you need the included dashboards, the `aws` module.

```
use cinghie\aws\components\AWS;
use cinghie\aws\AWS as AWSModule;

return [
    'components' => [
        'aws' => [
            'class' => AWS::class,
            'region' => 'eu-south-1',
            'version' => 'latest',
        ],
    ],
    'modules' => [
        'aws' => [
            'class' => AWSModule::class,
            'awsRoles' => ['admin'],
        ],
    ],
];
```

With this configuration credentials are not stored in code: AWS SDK uses its native credential provider chain, including environment variables, IAM roles, container credentials, local profiles, and other supported providers.

Credentials
-----------

[](#credentials)

### Recommended Option: IAM, Env Or Provider Chain

[](#recommended-option-iam-env-or-provider-chain)

```
'aws' => [
    'class' => cinghie\aws\components\AWS::class,
    'region' => 'eu-south-1',
    'version' => 'latest',
],
```

Environment variables supported by AWS SDK:

```
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_DEFAULT_REGION=eu-south-1
```

### Local AWS Profile

[](#local-aws-profile)

```
'aws' => [
    'class' => cinghie\aws\components\AWS::class,
    'profile' => 'default',
    'region' => 'eu-south-1',
    'version' => 'latest',
],
```

### Static Credentials

[](#static-credentials)

Use static credentials only when an IAM, env, or profile based setup is not available.

```
'aws' => [
    'class' => cinghie\aws\components\AWS::class,
    'accessKey' => getenv('AWS_ACCESS_KEY_ID'),
    'secretKey' => getenv('AWS_SECRET_ACCESS_KEY'),
    'region' => 'eu-south-1',
    'version' => 'latest',
],
```

If only one of `accessKey` or `secretKey` is configured, the component throws `InvalidConfigException`.

AWS SDK Options
---------------

[](#aws-sdk-options)

The component exposes the main `Aws\Sdk` options:

```
'aws' => [
    'class' => cinghie\aws\components\AWS::class,
    'region' => 'eu-south-1',
    'version' => 'latest',
    'profile' => 'default',
    'endpoint' => 'http://minio:9000',
    'usePathStyleEndpoint' => true,
    'retries' => 3,
    'debug' => false,
    'http' => [
        'connect_timeout' => 5,
        'timeout' => 30,
    ],
    'sdkOptions' => [
        // Any other option supported by Aws\Sdk.
    ],
],
```

`sdkOptions` is passed directly to the `Aws\Sdk` constructor, so it can be used for advanced options that are not exposed as dedicated component properties.

Error Handling
--------------

[](#error-handling)

The services do not write flash messages and do not convert AWS errors into empty arrays.

The contract is:

- success: returns `Aws\Result`
- AWS error: throws `Aws\Exception\AwsException`
- invalid local input: throws `InvalidArgumentException`

Example:

```
use Aws\Exception\AwsException;
use cinghie\aws\models\S3;

try {
    $s3 = Yii::createObject(S3::class);
    $buckets = $s3->getBuckets();
} catch (AwsException $e) {
    Yii::error($e->getMessage(), __METHOD__);
    Yii::$app->session->setFlash('error', Yii::t('aws', 'Unable to load AWS data.'));
} catch (InvalidArgumentException $e) {
    Yii::$app->session->setFlash('error', $e->getMessage());
}
```

The included dashboards already catch `AwsException` in their controllers, log the detailed error, and display a generic message in the UI.

Input Validation
----------------

[](#input-validation)

The wrappers validate common input mistakes before calling AWS. This keeps application errors deterministic and avoids sending obviously invalid requests to AWS.

Validated inputs include:

- S3 bucket names
- SNS topic names and topic ARNs
- SNS subscription protocols and endpoints
- SES email addresses
- SES domain names
- SES template names
- SES recipient lists
- SES receipt filter policies, limited to `Allow` or `Block`
- SES policy JSON strings

These checks are intentionally strict for common application use. AWS remains the final authority for service-specific edge cases.

Client Injection And Tests
--------------------------

[](#client-injection-and-tests)

Models can receive specific AWS clients through Yii configuration. This simplifies testing, mocking, and application-level overrides.

```
use Aws\S3\S3Client;
use cinghie\aws\models\S3;

$client = new S3Client([
    'region' => 'eu-south-1',
    'version' => 'latest',
]);

$s3 = Yii::createObject([
    'class' => S3::class,
    's3Client' => $client,
]);
```

Available setters:

- `S3::setS3Client(S3Client $client)`
- `SES::setSesClient(SesClient $client)`
- `SNS::setSnsClient(SnsClient $client)`

If no client is injected, the model creates it from the `Yii::$app->aws->sdk` component.

Amazon S3
---------

[](#amazon-s3)

### Basic Usage

[](#basic-usage)

```
use Aws\Exception\AwsException;
use cinghie\aws\models\S3;

try {
    $s3 = Yii::createObject(S3::class);
    $result = $s3->getBuckets();

    foreach ($result['Buckets'] as $bucket) {
        echo $bucket['Name'] . PHP_EOL;
    }
} catch (AwsException $e) {
    Yii::error($e->getMessage(), __METHOD__);
}
```

### Create A Bucket

[](#create-a-bucket)

```
$s3 = Yii::createObject(\cinghie\aws\models\S3::class);
$result = $s3->createBucket('my-application-bucket');
```

### Upload A File

[](#upload-a-file)

```
$s3 = Yii::createObject(\cinghie\aws\models\S3::class);

$result = $s3->putObjectInBucket(
    'my-application-bucket',
    'documents/report.pdf',
    Yii::getAlias('@runtime/report.pdf')
);
```

### MinIO Or S3-Compatible Configuration

[](#minio-or-s3-compatible-configuration)

```
'aws' => [
    'class' => cinghie\aws\components\AWS::class,
    'region' => 'us-east-1',
    'version' => 'latest',
    'endpoint' => 'http://minio:9000',
    'usePathStyleEndpoint' => true,
    'accessKey' => getenv('MINIO_ACCESS_KEY'),
    'secretKey' => getenv('MINIO_SECRET_KEY'),
],
```

Amazon SES
----------

[](#amazon-ses)

### Verify Identities

[](#verify-identities)

```
use Aws\Exception\AwsException;
use cinghie\aws\models\SES;

try {
    $ses = Yii::createObject(SES::class);
    $result = $ses->verifyEmailIdentity('sender@example.com');
} catch (AwsException $e) {
    Yii::error($e->getMessage(), __METHOD__);
}
```

### List Email Identities

[](#list-email-identities)

```
$ses = Yii::createObject(\cinghie\aws\models\SES::class);
$result = $ses->listIdentities();
```

### Create A Template

[](#create-a-template)

```
$ses = Yii::createObject(\cinghie\aws\models\SES::class);

$result = $ses->createTemplate(
    'OrderConfirmation',
    'Order confirmation',
    'Thank you for your order',
    'Thank you for your order'
);
```

### Send A Templated Email

[](#send-a-templated-email)

```
$ses = Yii::createObject(\cinghie\aws\models\SES::class);

$result = $ses->sendTemplatedEmail(
    'OrderConfirmation',
    'sender@example.com',
    ['customer@example.com'],
    'reply@example.com'
);
```

### Create A Receipt Filter

[](#create-a-receipt-filter)

```
$ses = Yii::createObject(\cinghie\aws\models\SES::class);

$result = $ses->createEmailFilter(
    'OfficeIpAllowList',
    '203.0.113.10/32',
    'Allow'
);
```

### Create A Receipt Rule With Recipients

[](#create-a-receipt-rule-with-recipients)

```
$ses = Yii::createObject(\cinghie\aws\models\SES::class);

$result = $ses->createReceiptRule(
    'InboundToS3',
    'DefaultRuleSet',
    'my-application-bucket',
    ['inbound@example.com']
);
```

Amazon SNS
----------

[](#amazon-sns)

SNS methods no longer have fake default values: protocol, endpoint, and topic must always be passed explicitly.

### Create A Topic

[](#create-a-topic)

```
use Aws\Exception\AwsException;
use cinghie\aws\models\SNS;

try {
    $sns = Yii::createObject(SNS::class);
    $result = $sns->createTopic('orders-events');
    $topicArn = $result['TopicArn'];
} catch (AwsException $e) {
    Yii::error($e->getMessage(), __METHOD__);
}
```

### Subscribe An Email Endpoint

[](#subscribe-an-email-endpoint)

```
$sns = Yii::createObject(\cinghie\aws\models\SNS::class);

$result = $sns->subscribeEmailToTopic(
    'email',
    'operator@example.com',
    'arn:aws:sns:eu-south-1:123456789012:orders-events'
);
```

### Subscribe An HTTPS Endpoint

[](#subscribe-an-https-endpoint)

```
$sns = Yii::createObject(\cinghie\aws\models\SNS::class);

$result = $sns->subscribeAppEndPointToTopic(
    'https',
    'https://example.com/sns/webhook',
    'arn:aws:sns:eu-south-1:123456789012:orders-events'
);
```

Yii2 Dashboards
---------------

[](#yii2-dashboards)

The module exposes basic dashboards for the services:

- `/aws/s3/index`
- `/aws/ses/index`
- `/aws/sns/index`

Access is controlled by `awsRoles`:

```
'modules' => [
    'aws' => [
        'class' => cinghie\aws\AWS::class,
        'awsRoles' => ['admin'],
    ],
],
```

Overrides
---------

[](#overrides)

### Controllers

[](#controllers)

```
'modules' => [
    'aws' => [
        'class' => cinghie\aws\AWS::class,
        'controllerMap' => [
            's3' => 'app\controllers\S3Controller',
            'ses' => 'app\controllers\SesController',
            'sns' => 'app\controllers\SnsController',
        ],
    ],
],
```

### Models

[](#models)

```
'modules' => [
    'aws' => [
        'class' => cinghie\aws\AWS::class,
        'modelMap' => [
            'S3' => 'app\models\S3',
            'SES' => 'app\models\SES',
            'SNS' => 'app\models\SNS',
        ],
    ],
],
```

The bootstrap process registers model overrides in Yii's DI container. Query aliases such as `S3Query`, `SESQuery`, and `SNSQuery` are registered only when the mapped class extends `yii\db\ActiveRecord`; plain service models are not treated as ActiveRecord classes.

### Views

[](#views)

```
'components' => [
    'view' => [
        'theme' => [
            'pathMap' => [
                '@cinghie/aws/views/s3' => '@app/views/aws/s3',
                '@cinghie/aws/views/ses' => '@app/views/aws/ses',
                '@cinghie/aws/views/sns' => '@app/views/aws/sns',
            ],
        ],
    ],
],
```

Frontend Filter
---------------

[](#frontend-filter)

In a Yii2 Advanced App, frontend module actions can be hidden with the included filter.

```
use cinghie\aws\filters\FrontendFilter as AwsFrontendFilter;

'modules' => [
    'aws' => [
        'class' => cinghie\aws\AWS::class,
        'as frontend' => AwsFrontendFilter::class,
    ],
],
```

Operational Suggestions
-----------------------

[](#operational-suggestions)

- Prefer IAM roles, environment variables, or AWS profiles over static credentials.
- Do not store access keys or secret keys in the repository.
- Always handle `AwsException` at the application layer.
- Inject specific clients in tests instead of calling real AWS services.
- Use `endpoint` and `usePathStyleEndpoint` for MinIO, LocalStack, and S3-compatible services.
- Avoid demo values or placeholders in production code: always pass explicit parameters.

AWS Documentation
-----------------

[](#aws-documentation)

- S3:
- SES:
- SNS:

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance59

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

2640d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfedb99c8fcbaf668c4f9779d341997b84029673eda224241b11732981cbc8b2?d=identicon)[cinghie](/maintainers/cinghie)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/cinghie-yii2-aws/health.svg)

```
[![Health](https://phpackages.com/badges/cinghie-yii2-aws/health.svg)](https://phpackages.com/packages/cinghie-yii2-aws)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[altis/core

Core module for Altis

19228.0k3](/packages/altis-core)

PHPackages © 2026

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