async-aws/s3
AsyncAws S3 is a lightweight, async-friendly AWS S3 API client for PHP. Install via Composer and use it to upload, download, list, and manage buckets and objects with a modern, typed client. Part of the AsyncAws suite.
Pros:
int for ContentLength instead of string) improves IDE support and reduces runtime errors.us-isob-west-1, eusc-de-east-1) via configurable endpoints, critical for global Laravel deployments.Cons:
bind() or service container) or a facade wrapper.AsyncAws\S3\Middleware\RetryMiddleware) or queue workers for Laravel’s synchronous HTTP layer.Filesystem contracts (e.g., Illuminate\Contracts\Filesystem\Filesystem) for S3 via a custom adapter (e.g., AsyncAwsS3Adapter).S3UploadJob) for background processing.aws/aws-sdk-php, this introduces dual SDK maintenance (though AsyncAws is lighter).fruitcake/laravel-caching or spatie/laravel-medialibrary if they use the AWSSDK.try/catch) won’t catch them without middleware.us-east-1 vs. us-east-1-fips) can cause silent failures.AsyncAws\S3\Middleware\RetryMiddleware with exponential backoff.S3Client::promise()->getObject()) for critical paths.AsyncAws\S3\Result\UploadPartOutput + custom events)?sendChunkedBody) be enabled for large files (>100MB)?AsyncAws\S3\Middleware\ThrottleMiddleware)?AsyncAws\S3\S3Client as a singleton with AWS credentials bound to config('services.aws').
$app->bind('async-aws.s3', fn() => new S3Client([
'credentials' => $app['config']['services.aws'],
'region' => $app['config']['services.aws.region'],
'endpoint' => env('AWS_ENDPOINT'), // For VPC/S3 Express
]));
Illuminate\Filesystem\Filesystem to delegate to S3Client:
class AsyncAwsS3Adapter extends Filesystem {
public function __construct(S3Client $client) {
$this->client = $client;
}
public function put($path, $contents, array $options = []) {
$this->client->putObject([
'Bucket' => $this->client->getBucket(),
'Key' => $path,
'Body' => $contents,
'ContentType' => $options['content_type'] ?? 'application/octet-stream',
]);
}
}
S3UploadJob) with dispatchSync() for immediate execution or dispatch() for background processing.await for critical paths (PHP 8.1+):
$result = await $s3Client->getObject(['Bucket' => 'bucket', 'Key' => 'file.txt']);
AsyncAws\S3\Middleware\RetryMiddleware globally for retries:
$s3Client->registerMiddleware(new RetryMiddleware());
async-aws/s3.S3Client::promise()->getObject()) to avoid async complexity.async-aws/s3.deprecated() helper.async-aws/s3:2.x (PHP 8.1) with a polyfill.aws/aws-sdk-php, remove it or use a composer alias to avoid version conflicts.S3Adapter with AsyncAwsS3Adapter.S3CacheStore to use async-aws/s3.php.ini to enable opcache.jit_buffer_size (for PHP 8.2+ async optimizations)..env:
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_DEFAULT_REGION=us-east-1
composer require async-aws/s3.AppServiceProvider.S3Client in unit tests using AsyncAws\S3\Mock\S3Client.await in PHPUnit.config/services.php.async-aws/s3 for breakingHow can I help you explore Laravel packages today?