league/flysystem-aws-s3-v3
Flysystem AWS S3 v3 adapter for PHP. Use it to store and retrieve files on Amazon S3 via the Flysystem filesystem abstraction. Install with composer require league/flysystem-aws-s3-v3; docs available on flysystem.thephpleague.com.
Install the package via Composer to enable AWS S3 integration with Flysystem:
composer require league/flysystem-aws-s3-v3
In Laravel, the most common first step is configuring a new S3 disk in config/filesystems.php using the s3 driver. The adapter auto-registers when league/flysystem-bundle or league/flysystem-aws-s3-v3 is present. Start by uploading a file:
Storage::disk('s3')->put('avatars/me.jpg', $fileContent);
For non-Laravel apps, manually instantiate the AwsS3V3Adapter with an S3Client and wrap it in a Filesystem. Check the official docs for credential options (ENV, IAM roles, config arrays).
config/filesystems.php to define custom S3 disks with environment-driven config (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_BUCKET, AWS_DEFAULT_REGION). Leverage Laravel’s Storage::disk('custom-s3') for contextual logic (e.g., public assets vs. user uploads).League\Flysystem\FilesystemOperator (or FilesystemInterface) via constructor/type-hinting—especially useful for unit tests where you swap adapters.$filesystem->write('private-report.pdf', $content, ['visibility' => 'private']);
Combine with bucket policies to ensure public files don’t accidentally become private.AsyncFilesystemDecorator to avoid blocking I/O:
$asyncFs = new AsyncFilesystemDecorator($filesystem);
$promise = $asyncFs->writeAsync('logs/app.log', $data);
FilesystemOperator in unit tests. For integration tests, use league/flysystem-memory or awssum/laravel-test-s3 to avoid real API calls.'path' => 'uploads' + filename avatar.png yields key uploads/avatar.png. Avoid empty strings or '.' as prefix—use 'uploads/' for clarity, but never '/' (results in 'filename', not '/filename').S3Client instance (e.g., via Laravel’s container or manual DI). Creating new clients per request kills performance and exhausts connections.public visibility, S3 blocks access if bucket policy denies s3:GetObject for public users. Verify bucket-level permissions in AWS Console > Permissions > Block public access.'url' => env('AWS_URL') and 'endpoint' => env('AWS_ENDPOINT') in config, and enable 'use_path_style_endpoint' => true in the SDK client config.Visibility::PUBLIC maps to acl: 'public-read', but S3 requires bucket policy or object ownership settings to allow this. In newer buckets with Object Ownership: Object Writer, ACLs are ignored—set visibility via bucket policies instead.img-abc123.jpg) or use Storage::temporaryUrl() for signed URLs.aws/aws-sdk-php) ≥3.260. Older SDK versions break this adapter. Run composer show aws/aws-sdk-php to verify—Lock to a known-good patch version in production if needed.How can I help you explore Laravel packages today?