Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Core Laravel Package

async-aws/core

Shared core library for AsyncAws services: common utilities, HTTP/stream handling, exceptions, and AWS request/response infrastructure. Includes an STS client for authentication and credentials. Install via composer require async-aws/core.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • AWS SDK Abstraction: The package provides a high-level, asynchronous PHP SDK for AWS services, leveraging Laravel’s dependency injection and Symfony’s HTTP client. This aligns well with Laravel’s ecosystem, especially for applications requiring scalable, non-blocking AWS interactions (e.g., background jobs, real-time processing).
  • Modular Design: The core package includes STS (Security Token Service) and shared utilities, while service-specific clients (e.g., S3, DynamoDB) are modular. This enables gradual adoption—start with core authentication, then extend to specific services.
  • Asynchronous Support: Built on Symfony’s HttpClient with retry mechanisms, making it ideal for Laravel Queues, Horizon, or Livewire where async operations are critical.
  • Laravel Synergy: Works seamlessly with Laravel’s Service Providers, Config, and Cache (e.g., credential caching via PsrCacheProvider or Symfony’s cache).

Integration Feasibility

  • Low Friction: Composer install (composer require async-aws/core) and minimal boilerplate. Laravel’s Service Container can bind AwsClientFactory and service clients (e.g., S3Client) as singletons.
  • Configuration: Supports AWS config files (~/.aws/config), environment variables, and Laravel’s config/aws.php. The ConfigurationProvider merges profiles across files, reducing manual setup.
  • Authentication: Native support for IAM roles, SSO, ECS credentials, and Web Identity (OIDC/JWT), critical for Laravel deployments (e.g., ECS Fargate, EKS).
  • Mocking: ResultMockFactory enables unit testing without AWS calls, valuable for Laravel’s testing stack (Pest, PHPUnit).

Technical Risk

  • PHP 8.2+ Requirement: Laravel 10+ uses PHP 8.2+, so this is non-negotiable but aligns with modern Laravel.
  • Symfony Dependencies: Requires symfony/http-client (v5.4+) and symfony/cache (v5.4+). Laravel already includes these, but version conflicts could arise if other packages enforce stricter versions.
  • Async Complexity: While the SDK handles retries and async logic, Laravel’s synchronous middleware (e.g., routes) may need adaptation (e.g., using sync queues for immediate responses).
  • Error Handling: Custom exceptions (AsyncAws\Core\Exception\*) must be mapped to Laravel’s exception handlers (e.g., App\Exceptions\Handler) to ensure consistent error responses.

Key Questions

  1. Async Strategy:
    • Will async operations be used in Laravel routes (risk: blocking) or queues/jobs (recommended)?
    • How will timeouts (e.g., HTTP client vs. Laravel’s max_execution_time) be managed?
  2. Credential Management:
    • Should Laravel’s Cache or Environment variables override AWS config files? (Use ConfigurationProvider::merge().)
    • For serverless (e.g., Lambda), how will IAM roles be handled? (Use AwsClientFactory with roleArn.)
  3. Testing:
    • Will ResultMockFactory replace Laravel’s Mockery for AWS service tests?
    • How will feature flags (e.g., SSO) be tested in CI?
  4. Monitoring:
    • Should the debug config option log AWS requests to Laravel Log or a dedicated system (e.g., Datadog)?
  5. Scaling:
    • For high-throughput apps, will AwsRetryStrategy need tuning (e.g., exponential backoff)?

Integration Approach

Stack Fit

  • Laravel Core: The package integrates natively with:
    • Service Container: Bind clients as singletons in AppServiceProvider.
    • Config: Use config('aws') to override defaults (e.g., region, endpoint).
    • Cache: Leverage PsrCacheProvider for credential caching (e.g., Redis).
    • Logging: Use Laravel’s Log channel for AWS request/response debugging.
  • Queues/Jobs: Ideal for delayed AWS operations (e.g., S3 uploads, DynamoDB batch writes).
  • Livewire/Inertia: Async AWS calls can power real-time updates without blocking UI.
  • API Routes: Use sync queues for immediate responses (e.g., S3::putObject()).

Migration Path

  1. Phase 1: Core Setup
    • Install async-aws/core and async-aws/s3 (example).
    • Configure in config/aws.php:
      'default' => 's3',
      'clients' => [
          's3' => [
              'region' => env('AWS_REGION', 'us-east-1'),
              'version' => 'latest',
          ],
      ],
      
    • Bind clients in AppServiceProvider:
      $this->app->singleton(S3Client::class, fn($app) =>
          AwsClientFactory::create($app['config']['aws.clients.s3'])
      );
      
  2. Phase 2: Authentication
    • Use StsClient for temporary credentials (e.g., cross-account access).
    • Example:
      $sts = $this->app->make(StsClient::class);
      $credentials = $sts->assumeRole(['RoleArn' => 'arn:aws:iam::123:role/Example']);
      
  3. Phase 3: Async Workflows
    • Dispatch jobs for long-running tasks:
      ProcessS3Upload::dispatch($file, $bucket);
      
    • Use AwsRetryStrategy in jobs for resilience.
  4. Phase 4: Testing
    • Replace AWS calls with ResultMockFactory:
      $mock = ResultMockFactory::createFailing(
          new PutObjectInput(),
          new PutObjectResult(),
          new ClientException('Test error', 400)
      );
      

Compatibility

  • Laravel 10+: Full compatibility (PHP 8.2+).
  • Laravel 9: Possible with PHP 8.1, but deprecated (see changelog 1.22.1).
  • AWS SDK Alternatives: Replaces aws/aws-sdk-php (v3) with a modern, async-first approach.
  • Third-Party Packages: Conflicts unlikely, but audit symfony/http-client versions.

Sequencing

  1. Start with STS: Implement authentication first (e.g., assume role for Lambda).
  2. Add Critical Services: Prioritize S3, DynamoDB, or SQS based on app needs.
  3. Optimize Async: Gradually move synchronous AWS calls to queues.
  4. Monitor: Use debug: true in config to log requests during ramp-up.

Operational Impact

Maintenance

  • Dependency Updates: Monitor async-aws/core for PHP 8.3+ compatibility (changelog 1.28.0 dropped PHP <8.2).
  • Backward Compatibility: Breaking changes are rare (e.g., 2.0 will remove %region% placeholders).
  • Laravel-Specific: Override AwsClientFactory to inject Laravel’s cache or config:
    $factory = new AwsClientFactory(
        new ConfigurationProvider($config),
        new SymfonyCacheProvider($app['cache']),
        new RetryableHttpClient($app['http.client'])
    );
    

Support

  • Debugging: Use debug: true in config to log AWS requests/responses to Laravel Log.
  • Error Mapping: Extend App\Exceptions\Handler to convert AsyncAws\Core\Exception\* to Laravel responses:
    public function render($request, Throwable $exception) {
        if ($exception instanceof ClientException) {
            return response()->json(['error' => $exception->getAwsErrorMessage()], 400);
        }
        return parent::render($request, $exception);
    }
    
  • Community: Limited stars (102) but active maintainers (recent 1.28.x releases). Use GitHub Issues for support.

Scaling

  • Horizontal Scaling: Stateless clients work well in Laravel Forge/Vapor.
  • Credential Caching: Use PsrCacheProvider with Redis to avoid STS token refreshes.
  • Rate Limiting: Configure AwsRetryStrategy to avoid throttling:
    $client = AwsClientFactory::create([
        'retry_strategy' => new AwsRetryStrategy(3, 100, ['429' => true]),
    ]);
    
  • Load Testing: Simulate async workloads with Laravel Dusk or Pest.

Failure Modes

| Failure Scenario | Mitigation | Laravel Integration | |--------------------------------|----------------------------------------------------------------------------

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui