innmind / s3
Manipulate a S3 bucket
6.0.0
2026-04-12 14:43 UTC
Requires
- php: ~8.4
- innmind/foundation: ~2.1
Requires (Dev)
- innmind/black-box: ~6.12
- innmind/coding-standard: ~2.0
- innmind/static-analysis: ~1.3
- symfony/dotenv: ^8.0
README
Minimalist abstraction to work with any S3 bucket.
Installation
composer require innmind/s3
Usage
use Innmind\S3\{ Factory, Region, }; use Innmind\OperatingSystem\Factory as OSFactory; use Innmind\Filesystem\File\Content; use Innmind\Url\{ Url, Path, }; $os = OSFactory::build(); $bucket = Factory::of($os)->build( Url::of('https://acces_key:acces_secret@bucket-name.s3.region-name.scw.cloud/'), Region::of('region-name'), ); $file = $bucket->get(Path::of('some-file.txt'))->match( static fn(Content $file) => $file, static fn() => throw new \RuntimeException('File does not exist'), ); $bucket->upload(Path::of('some-other-name.txt'), $file)->match( // essentially this will copy the file static fn() => null, // everything ok static fn(\Throwable $e) => throw $e, );