Skip to content

Craftcms release #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 48 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Yii2 DynamoDB Cache, Session, and Queue Driver Implementation
# DynamoDB Cache, Session, and Queue for Yii 2

[![Latest Version on Packagist](https://img.shields.io/packagist/v/pixelandtonic/yii2-dynamodb.svg?style=flat-square)](https://packagist.org/packages/pixelandtonic/yii2-dynamodb)
[![Total Downloads](https://img.shields.io/packagist/dt/pixelandtonic/yii2-dynamodb.svg?style=flat-square)](https://packagist.org/packages/pixelandtonic/yii2-dynamodb)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/pixelandtonic/yii2-dynamodb/run-tests?label=tests)](https://github.com/pixelandtonic/yii2-dynamodb/actions?query=workflow%3Arun-tests+branch%3Amaster)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/craftcms/yii2-dynamodb.svg?style=flat-square)](https://packagist.org/packages/craftcms/yii2-dynamodb)
[![Total Downloads](https://img.shields.io/packagist/dt/craftcms/yii2-dynamodb.svg?style=flat-square)](https://packagist.org/packages/craftcms/yii2-dynamodb)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/craftcms/yii2-dynamodb/run-tests?label=tests)](https://github.com/pixelandtonic/yii2-dynamodb/actions?query=workflow%3Aci+branch%3Amaster)

Easily use DynamoDB as a [cache](https://www.yiiframework.com/doc/guide/2.0/en/caching-overview), [session](https://www.yiiframework.com/doc/guide/2.0/en/runtime-sessions-cookies), or [queue](https://github.com/yiisoft/yii2-queue) using this library in your Yii2 or Craft CMS projects.

Expand All @@ -13,12 +13,12 @@ Easily use DynamoDB as a [cache](https://www.yiiframework.com/doc/guide/2.0/en/c
You can install the package via composer:

```bash
composer require pixelandtonic/yii2-dynamodb
composer require craftcms/yii2-dynamodb
```

## Usage

This package provides three drivers for DynamoDB; caching, sessions, and queuing.
This package provides three Yii components for DynamoDB: cache, session, and queue.

### Cache Component

Expand All @@ -40,7 +40,7 @@ aws dynamodb create-table --table-name=my-app-cache-table \
In your `app.php`, configure the `cache` component to use the driver.

```php
use \pixelandtonic\dynamodb\drivers\DynamoDbCache;
use craftcms\dynamodb\DynamoDbCache;

return [
'bootstrap' => [
Expand All @@ -49,13 +49,19 @@ return [
'components' => [
'cache' => [
'class' => DynamoDbCache::class,
'table' => 'my-app-cache-table',
'tableIdAttribute' => 'id', // optional: defaults to id
'tableDataAttribute' => 'data', // optional: defaults to data
'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
'region' => '<region>', // optional: defaults to AWS_REGION env var
'dataAttribute' => 'data', // optional: defaults to data
'dynamoDb' => [
'table' => 'my-app-cache-table',
'partitionKeyAttribute' => 'id', // optional: defaults to 'PK'
'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
'region' => '<region>', // optional: defaults to AWS_REGION env var
'ttl' => 60*60*24, // optional: number of seconds until items are considered expired
'ttlAttribute' => 'expires' // optional: defaults to 'TTL'
'credentials' => [
'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
],
],
],
],
];
Expand All @@ -81,7 +87,7 @@ aws dynamodb create-table --table-name=my-app-session-table \
In your `app.php`, configure the `session` component to use the driver.

```php
use \pixelandtonic\dynamodb\drivers\DynamoDbSession;
use craftcms\dynamodb\DynamoDbSession;

return [
'bootstrap' => [
Expand All @@ -90,13 +96,19 @@ return [
'components' => [
'session' => [
'class' => DynamoDbSession::class,
'table' => 'my-app-session-table',
'tableIdAttribute' => 'id', // optional: defaults to id
'tableDataAttribute' => 'data', // optional: defaults to data
'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
'region' => '<region>', // optional: defaults to AWS_REGION env var
'dataAttribute' => 'data', // optional: defaults to data
'dynamoDb' => [
'table' => 'my-app-session-table',
'partitionKeyAttribute' => 'id', // optional: defaults to 'PK'
'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
'region' => '<region>', // optional: defaults to AWS_REGION env var
'ttl' => 60*60*24, // optional: number of seconds until items are considered expired
'ttlAttribute' => 'expires' // optional: defaults to 'TTL'
'credentials' => [
'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
],
],
],
],
];
Expand All @@ -122,7 +134,7 @@ aws dynamodb create-table --table-name=my-app-queue-table \
In your `app.php`, configure the `queue` component to use the driver.

```php
use \pixelandtonic\dynamodb\drivers\DynamoDbQueue;
use craftcms\dynamodb\DynamoDbQueue;

return [
'bootstrap' => [
Expand All @@ -131,13 +143,18 @@ return [
'components' => [
'queue' => [
'class' => DynamoDbQueue::class,
'table' => 'my-app-queue-table',
'tableIdAttribute' => 'id', // optional: defaults to id
'tableDataAttribute' => 'data', // optional: defaults to data
'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
'region' => '<region>', // optional: defaults to AWS_REGION env var
'dynamoDb' => [
'table' => 'my-app-queue-table',
'partitionKeyAttribute' => 'id', // optional: defaults to 'PK'
'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
'region' => '<region>', // optional: defaults to AWS_REGION env var
'ttl' => 60*60*24, // optional: number of seconds until items are considered expired
'ttlAttribute' => 'expires' // optional: defaults to 'TTL'
'credentials' => [
'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
],
],
],
],
];
Expand All @@ -160,6 +177,7 @@ To make the setup and testing easier, you can run the following Composer scripts
## Credits

- [Jason McCallister](https://github.com/jasonmccallister)
- [Tim Kelty](https://github.com/timkelty)
- [All Contributors](../../contributors)

## License
Expand Down
136 changes: 68 additions & 68 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
{
"name": "pixelandtonic/yii2-dynamodb",
"description": "Yii2 implementation of a cache, session, and queue driver for DynamoDB",
"keywords": [
"yii2",
"dynamodb",
"cache",
"queue",
"session"
],
"authors": [
{
"name": "Pixel & Tonic",
"homepage": "https://pixelandtonic.com/"
}
],
"license": "MIT",
"support": {
"email": "support@pixelandtonic.com",
"issues": "https://github.com/pixelandtonic/yii2-dynamodb/issues?state=open",
"source": "https://github.com/pixelandtonic/yii2-dynamodb",
"docs": "https://github.com/pixelandtonic/yii2-dynamodb/blob/README.md"
},
"require": {
"aws/aws-sdk-php": ">=2.4",
"ext-json": "*",
"yiisoft/yii2": "~2.0.45.0",
"yiisoft/yii2-queue": "~2.3.2"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main"
},
"autoload": {
"psr-4": {
"pixelandtonic\\dynamodb\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"tests\\": "tests"
}
},
"scripts": {
"setup": [
"@docker",
"@tables"
"name": "craftcms/yii2-dynamodb",
"description": "Yii2 implementation of a cache, session, and queue driver for DynamoDB",
"keywords": [
"yii2",
"dynamodb",
"cache",
"queue",
"session"
],
"docker": "docker-compose up -d dynamodb",
"test": "vendor/bin/phpunit --testdox",
"tables": "make tables",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --ansi --fix",
"phpstan": "phpstan --memory-limit=1G"
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
"authors": [
{
"name": "Pixel & Tonic",
"homepage": "https://pixelandtonic.com/"
}
],
"license": "MIT",
"support": {
"email": "support@craftcms.com",
"issues": "https://github.com/craftcms/yii2-dynamodb/issues?state=open",
"source": "https://github.com/craftcms/yii2-dynamodb",
"docs": "https://github.com/craftcms/yii2-dynamodb/blob/README.md"
},
"require": {
"aws/aws-sdk-php": ">=2.4",
"ext-json": "*",
"yiisoft/yii2": "~2.0.45.0",
"yiisoft/yii2-queue": "~2.3.2"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main"
},
"autoload": {
"psr-4": {
"craftcms\\dynamodb\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"tests\\": "tests"
}
},
"scripts": {
"setup": [
"@docker",
"@tables"
],
"docker": "docker-compose up -d dynamodb",
"test": "vendor/bin/phpunit --testdox",
"tables": "make tables",
"check-cs": "ecs check --ansi",
"fix-cs": "ecs check --ansi --fix",
"phpstan": "phpstan --memory-limit=1G"
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
},
"platform": {
"php": "8.0.2"
}
},
"platform": {
"php": "8.0.2"
"provide": {
"bower-asset/jquery": "*",
"bower-asset/inputmask": "*",
"bower-asset/punycode": "*",
"bower-asset/yii2-pjax": "*",
"bower-asset/bootstrap": "*",
"bower-asset/typeahead.js": "*"
}
},
"provide": {
"bower-asset/jquery": "*",
"bower-asset/inputmask": "*",
"bower-asset/punycode": "*",
"bower-asset/yii2-pjax": "*",
"bower-asset/bootstrap": "*",
"bower-asset/typeahead.js": "*"
}
}
2 changes: 1 addition & 1 deletion src/DynamoDbCache.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace pixelandtonic\dynamodb;
namespace craftcms\dynamodb;

use Aws\DynamoDb\Exception\DynamoDbException;
use Yii;
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoDbConnection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace pixelandtonic\dynamodb;
namespace craftcms\dynamodb;

use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoDbQueue.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace pixelandtonic\dynamodb;
namespace craftcms\dynamodb;

use Aws\DynamoDb\Exception\DynamoDbException;
use Yii;
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoDbSession.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace pixelandtonic\dynamodb;
namespace craftcms\dynamodb;

use Aws\DynamoDb\Exception\DynamoDbException;
use Yii;
Expand Down
2 changes: 1 addition & 1 deletion tests/CacheTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace tests\cache;
namespace tests;

use Aws\Result;
use tests\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace tests;

use pixelandtonic\dynamodb\DynamoDbQueue;
use craftcms\dynamodb\DynamoDbQueue;
use Yii;
use yii\base\InvalidConfigException;
use yii\caching\CacheInterface;
Expand Down
8 changes: 4 additions & 4 deletions tests/config/app.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
use pixelandtonic\dynamodb\DynamoDbCache;
use pixelandtonic\dynamodb\DynamoDbConnection;
use pixelandtonic\dynamodb\DynamoDbQueue;
use pixelandtonic\dynamodb\DynamoDbSession;
use craftcms\dynamodb\DynamoDbCache;
use craftcms\dynamodb\DynamoDbConnection;
use craftcms\dynamodb\DynamoDbQueue;
use craftcms\dynamodb\DynamoDbSession;

$dynamoDbConfig = [
'class' => DynamoDbConnection::class,
Expand Down