imper86 / dynamodb-client-bundle
Symfony bundle for imper86/dynamodb-client
Package info
github.com/imper86/dynamodb-client-bundle
Type:symfony-bundle
pkg:composer/imper86/dynamodb-client-bundle
Requires
- php: >=8.1
- imper86/dynamodb-client: ^1.1
- psr/http-client: ^1.0
- symfony/config: ^6.4 || ^7.4 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.4 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.4 || ^8.0
Requires (Dev)
- captainhook/captainhook-phar: ^5.29
- friendsofphp/php-cs-fixer: ^3.95
- nyholm/psr7: ^1.8
- php-http/curl-client: ^2.4
- php-http/mock-client: ^1.6
- phpstan/phpstan: ^2.2
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^10.5 || ^11.5 || ^12.5 || ^13.3
- psr/http-message: ^1.0 || ^2.0
- rector/rector: ^2.6
- shipmonk/composer-dependency-analyser: ^1.8
- symfony/filesystem: ^6.4 || ^7.4 || ^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-28 19:18:10 UTC
README
A Symfony bundle that registers imper86/dynamodb-client
as an autowirable service. It works with Symfony 6.4, 7.4 and 8.x on PHP 8.1 or newer.
Installation
composer require imper86/dynamodb-client-bundle
The client needs a PSR-18 HTTP client and PSR-17 factories. If your app has none yet, install one, for example:
composer require symfony/http-client nyholm/psr7
With Symfony Flex, the recipe registers the bundle and adds AWS_REGION, AWS_ACCESS_KEY_ID and
AWS_SECRET_ACCESS_KEY to your .env. Without Flex, register the bundle yourself in
config/bundles.php:
return [ // ... Imper86\DynamoDBClientBundle\DynamoDBClientBundle::class => ['all' => true], ];
Configuration
The bundle needs no config file. By default it reads the standard AWS environment variables, from the
real environment or from your .env files:
# config/packages/imper86_dynamodb_client.yaml (these are the defaults) imper86_dynamodb_client: region: '%env(AWS_REGION)%' endpoint: ~ # optional; see "Custom endpoint" below credentials: key: '%env(AWS_ACCESS_KEY_ID)%' secret: '%env(AWS_SECRET_ACCESS_KEY)%' token: '%env(default::AWS_SESSION_TOKEN)%' # optional; null or '' means no session token
Create the file only to override a value, for example to use different variable names. region, key
and secret must not be empty. If AWS_REGION, AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY isn't
set anywhere, fetching the client throws an EnvNotFoundException. AWS_SESSION_TOKEN is optional. If
you point token at your own variable that may be empty, use the default:: processor as above, so
that an empty value means "no token".
Run bin/console config:dump-reference imper86_dynamodb_client to see the full reference.
Custom endpoint
By default requests go to https://dynamodb.<region>.amazonaws.com. To use another endpoint, such as
DynamoDB Local in
Docker, set endpoint to an absolute http or https url:
# config/packages/imper86_dynamodb_client.yaml when@dev: imper86_dynamodb_client: endpoint: 'http://localhost:8000'
DynamoDB Local does not check credentials, but requests are still signed, so the key and secret must not be empty. Any value works.
If you leave endpoint unset, the client reads AWS_ENDPOINT_URL_DYNAMODB and then
AWS_ENDPOINT_URL from the real process environment, the same way the AWS SDKs do. It does not see
.env files. To read the endpoint from .env, point endpoint at the variable with the default::
processor, so an empty or missing value means the regional AWS endpoint:
imper86_dynamodb_client: endpoint: '%env(default::DYNAMODB_ENDPOINT)%'
An invalid endpoint throws an InvalidArgumentException when the client is first fetched.
If the container has a Psr\Http\Client\ClientInterface service (for example from
symfony/http-client with nyholm/psr7 installed), the client sends its requests through it, so they
show up in the profiler. Otherwise it finds an HTTP client through
php-http/discovery.
Usage
Type your dependencies against DynamoDBClientInterface. It is the only autowirable type; the
concrete DynamoDBClient class is not.
use Imper86\DynamoDBClient\DynamoDBClientInterface; use Imper86\DynamoDBClient\ValueObject\StringList; final readonly class TableLister { public function __construct( private DynamoDBClientInterface $dynamoDB, ) {} public function list(): StringList { return $this->dynamoDB->listTables()->tableNames; } }
See the library README for the operations, request and response objects, and error handling.
License
MIT