- Can I use this package for DynamoDB write operations in Laravel?
- No, this package is read-only. For write operations (e.g., put, update, delete), you’ll need the full AWS SDK or another write-capable package. Design your system to handle writes elsewhere, like in API layers or Lambda functions, while using this package for reads.
- How do I install and configure AsyncAws DynamoDB in Laravel?
- Run `composer require async-aws/dynamo-db`, then bind the client to Laravel’s service container in `AppServiceProvider.php`. Configure AWS credentials via `config/aws.php` or environment variables (e.g., `AWS_ACCESS_KEY_ID`). Ensure your AWS region matches the DynamoDB endpoint.
- Does this package support batch reads or pagination for DynamoDB?
- Yes, it supports `BatchGetItem` for batch reads and handles pagination for `Scan` and `Query` operations. You can chain pagination methods like `paginate()` or manually process `LastEvaluatedKey` in responses for large datasets.
- Will this work with Laravel’s queue system for background jobs?
- Absolutely. Use this package in Laravel queue jobs (e.g., `queue:work`) to fetch DynamoDB data asynchronously without blocking HTTP requests. It’s ideal for read-heavy background tasks like analytics processing or caching layers.
- What Laravel and PHP versions does AsyncAws DynamoDB support?
- The package is compatible with PHP 8.1+ and Laravel 10.x/11.x (LTS releases). Always pin the `aws/aws-sdk-php` dependency in `composer.json` to avoid version conflicts, especially if using AWS SDK v3+ features.
- How do I test DynamoDB interactions locally with this package?
- Use LocalStack to spin up a local DynamoDB instance for integration tests. Mock responses with Laravel’s HTTP testing tools or libraries like Mockery. For assertions, create custom helpers (e.g., `assertQueryResultMatches()`) to validate DynamoDB responses.
- Does this package handle DynamoDB throttling or errors gracefully?
- The package propagates AWS errors (e.g., `ProvisionedThroughputExceeded`). Implement custom exceptions (e.g., `DynamoDbReadException`) to handle throttling or retries. For production, consider exponential backoff or fallback strategies like caching frequent queries.
- Can I use this package alongside the official AWS SDK for PHP?
- Yes, but avoid mixing them for the same DynamoDB operations to prevent conflicts. Use this package exclusively for reads and the AWS SDK for writes, or centralize DynamoDB access via a repository pattern to maintain consistency.
- What’s the performance difference between this package and the AWS SDK?
- This package is optimized for non-blocking reads, making it faster for high-QPS scenarios (e.g., 1000+ reads/sec) compared to the blocking AWS SDK. Benchmark your use case—it excels in Laravel queue workers or event listeners where async reads are critical.
- How do I handle strongly consistent reads with this package?
- Use the `ConsistentRead` parameter in `GetItem` or `Query` operations. The package supports this via standard DynamoDB API calls. For scans, note that consistency isn’t applicable—use `GetItem` for strongly consistent data retrieval.