- How does async-aws/core integrate with Laravel’s service container for AWS clients?
- The package uses dependency injection patterns that map cleanly to Laravel’s service container. You can bind the `AwsClientFactory` as a singleton or closure in your `AppServiceProvider` to leverage Laravel’s cache, HTTP client, and configuration systems. Example: `$this->app->bind(AwsClientFactory::class, fn() => new AwsClientFactory(new SymfonyCacheProvider($this->app['cache']), new SymfonyHttpClientProvider($this->app['http.client'])));`
- Does async-aws/core support Laravel’s config/aws.php for AWS credentials?
- Yes, the package reads AWS credentials from Laravel’s `config/aws.php` by default, falling back to environment variables or the `~/.aws/credentials` file. This ensures consistency with Laravel’s built-in AWS configuration patterns. For testing, you can also override credentials via the `Configuration` class or use hardcoded values.
- Can async-aws/core handle asynchronous AWS operations like streaming S3 responses?
- Absolutely. The package is designed for async-first workflows, supporting streaming responses (e.g., S3 downloads) and retryable HTTP clients via Symfony’s `RetryableHttpClient`. This aligns with Laravel’s growing async/await support in PHP 8.1+ and queue-based processing. For high-throughput operations, you can further optimize with chunked transfers.
- What Laravel versions and PHP requirements does async-aws/core support?
- The package requires **PHP 8.2+**, which may limit compatibility with Laravel 8.x projects. Laravel 9/10 users benefit from native support for Symfony components (e.g., `symfony/http-client`) and async features. For older Laravel versions, explicitly install dependencies like `symfony/http-client` and `symfony/cache` via Composer.
- How do I mock AWS responses in Laravel tests using async-aws/core?
- Use the `ResultMockFactory` to simulate AWS responses in tests. Bind it to the `AwsClientFactory` in your test setup, like this: `$this->app->bind(AwsClientFactory::class, fn() => new AwsClientFactory(new ResultMockFactory(), new SymfonyHttpClientProvider(new MockHttpClient())));`. This replaces real HTTP calls with predefined mock responses for unit/integration testing.
- Does async-aws/core support multi-region or multi-account AWS setups?
- Yes, the package supports dynamic region handling (e.g., `us-isob-west-1`) and custom endpoints via `AWS_ENDPOINT_URL`. For multi-account setups, use the `AwsClientFactory::createClient()` method with context-specific configurations, such as different credential providers or regions. This is useful for cross-account or multi-region deployments.
- How does async-aws/core handle AWS authentication (e.g., IAM roles, SSO, or temporary credentials)?
- The package includes built-in support for IAM roles (via `Ec2MetadataProvider` for EC2/ECS), temporary credentials (STS), and SSO/OIDC (via `SsoOidcProvider` in the `async-aws/sso` package). Configure credentials in `config/aws.php` or use environment variables. For SSO, ensure you install `async-aws/sso` separately.
- Are there performance considerations for high-throughput AWS operations (e.g., Kinesis or SQS)?
- The package optimizes for performance with features like chunked transfers (`sendChunkedBody`) and async streaming. For high-throughput services like Kinesis or SQS, ensure your Laravel app uses queue workers or async processing. Monitor memory usage, as streaming large responses may require adjustments to PHP’s `memory_limit` or Symfony’s HTTP client settings.
- How do I log AWS requests/responses in Laravel using async-aws/core?
- Enable debug mode in the package’s configuration (`debug: true`) to log HTTP requests/responses. For Laravel’s Monolog integration, extend the `AwsClientFactory` to format logs using Monolog’s processors. Example: Configure a custom `AwsLogger` that wraps Symfony’s `LoggerInterface` and integrates with Laravel’s logging channels.
- What are the alternatives to async-aws/core for Laravel AWS integrations?
- Alternatives include Laravel’s built-in `illuminate/aws` (basic AWS SDK wrapper), AWS SDK for PHP (v3), or Guzzle-based solutions like `php-http/guzzle7-adapter`. However, `async-aws/core` stands out for its **async-first design**, **modular architecture**, and **Symfony ecosystem compatibility**, making it ideal for modern Laravel apps requiring scalability and performance.