- Can I use this bundle directly in Laravel without Symfony components?
- No, this bundle is Symfony8-specific, but you can integrate it indirectly via Symfony’s HttpClient (standalone or via `symfony/http-client-bundle`) or wrap its AWS SDK logic in a Laravel service class. For example, use the bundle’s `AwsSecretsManagerClient` as a dependency in a custom Laravel service provider.
- Will this bundle work with Laravel’s native `config()` or `env()` system?
- It won’t replace Laravel’s `env()` for static configs, but you can extend Laravel’s `config()` system to fetch secrets dynamically at runtime. For example, create a custom config loader that queries AWS Secrets Manager via this bundle’s client. Use cases include per-request database credentials or rotating API keys.
- What Laravel versions does this bundle support?
- This bundle is Symfony8-only, so Laravel compatibility depends on your integration approach. Laravel 8+ works best due to PHP 8.1+ requirements. For Laravel 7 or older, you’d need to backport Symfony dependencies (e.g., HttpClient) or use a wrapper. Test thoroughly with your Laravel version.
- How do I handle secret caching in Laravel if this bundle uses Symfony’s CacheInterface?
- Symfony’s caching layer won’t integrate natively with Laravel’s `Cache` facade, but you can implement a dual strategy: cache secrets in Redis (via Laravel’s Cache) while respecting AWS’s TTL (Time-To-Live) for security. Alternatively, create a Laravel-compatible cache adapter for the bundle’s `CacheInterface`.
- Does this bundle support AWS SDK v3, and will it conflict with Laravel’s Guzzle or AWS SDK v2?
- Yes, the bundle uses AWS SDK v3. If your Laravel app uses `guzzlehttp/guzzle` or AWS SDK v2, you’ll need to ensure only one SDK version is loaded to avoid conflicts. Use Composer’s `replace` or `conflict` directives in `composer.json` to manage versions, or abstract the SDK behind a facade.
- How do I mock AWS Secrets Manager for unit testing in Laravel?
- Symfony’s HttpClient supports mocking, so you can create a Laravel test double for the bundle’s client. Use PHPUnit’s `createMock()` or Mockery to stub the `AwsSecretsManagerClient` interface. For integration tests, use AWS’s localstack or a mock AWS endpoint. Document your test setup for team consistency.
- Can this bundle replace Laravel’s `.env` file for production secrets?
- While possible, AWS Secrets Manager is better suited for runtime secrets (e.g., per-environment DB passwords) rather than static configs. Use this bundle to fetch secrets *in addition to* `.env`—for example, fall back to `.env` if AWS Secrets Manager is unavailable. Avoid hardcoding secrets entirely in `.env` for sensitive data.
- What’s the best way to handle secret rotation in Laravel with this bundle?
- AWS Secrets Manager handles rotation automatically, but Laravel’s `config:clear` won’t trigger secret refreshes. Implement a custom event listener or scheduled job (e.g., Laravel Queues) to refresh cached secrets after rotation. Use the bundle’s `getSecret()` method in your app’s bootstrapping logic (e.g., `AppServiceProvider`).
- Are there alternatives to this bundle for Laravel that don’t require Symfony?
- Yes, consider these Laravel-native options: `spatie/laravel-aws-secrets-manager` (simpler, no Symfony), `vlucas/phpdotenv` with AWS SDK v3, or a custom service class using `aws/aws-sdk-php` directly. Evaluate trade-offs: this bundle offers tighter Symfony integration but may require more abstraction for Laravel.
- How do I integrate this bundle with Laravel’s service container and dependency injection?
- Register the bundle’s services in a Laravel `ServiceProvider` by binding the `AwsSecretsManagerClient` to the container. Use Laravel’s `bind()` method to resolve Symfony’s `ContainerInterface` dependencies. For example: `app()->bind(AwsSecretsManagerClient::class, fn() => new AwsSecretsManagerClient($awsConfig));`. Document dependencies clearly for maintainability.