1tomany/storage-bundle
Symfony bundle for uploading files to remote storage (Amazon S3/R2, GCS, Azure) with a simple client-based config. Includes an Amazon S3-compatible client plus a mock client for fast, offline testing, and optional custom URLs for CDN/public buckets.
ClientInterface, ActionInterface) maps cleanly to Laravel’s service container and facades. Laravel’s Storage facade and Filesystem contracts can wrap the bundle’s clients with minimal abstraction overhead.StorageBundle facade; requires custom binding (e.g., app()->singleton(UploadActionInterface::class, fn() => new UploadAction($client))).storage:file-uploaded events won’t auto-trigger; manual dispatch needed in UploadActionInterface::act().ShouldQueue for async uploads). Would need custom UploadJob extending ActionInterface.config/filesystems.php but extends it with mock testing and CDN URL customization, filling gaps in Laravel’s native storage drivers.ParameterBag) may require polyfills.fruitcake/laravel-aws or spatie/laravel-aws may conflict with aws/aws-sdk-php-symfony. Requires dependency resolution (e.g., replace in composer.json).Storage facade expects real filesystems; mock client would need a Laravel-specific adapter (e.g., InMemoryFilesystem).Storage facade generates URLs via Storage::url(). Overriding this for CDN paths requires middleware or facade decorators.Exception hierarchy differs from Laravel’s. Custom exception mappers may be needed (e.g., S3Exception → StorageException)..env can mirror Symfony’s onetomany_storage.yaml (e.g., STORAGE_CLIENT=amazon, AWS_BUCKET=laravel-bucket).Storage facade usage? Will we deprecate the facade or wrap it?Storage::fake()? If not, how will we hybridize them?UploadActionInterface in Pest/PHPUnit?STORAGE_CUSTOM_URL per .env)?cache filesystem for metadata? The bundle lacks local filesystem support.custom_url vs. native S3 URLs.ClientInterface and ActionInterface to Laravel’s container via AppServiceProvider:
public function register(): void {
$this->app->bind(ClientInterface::class, fn() => new AmazonClient(
config('onetomany_storage.amazon_client')
));
$this->app->bind(UploadActionInterface::class, UploadAction::class);
}
onetomany_storage.yaml into Laravel’s config/storage.php:
'onetomany' => [
'client' => env('STORAGE_CLIENT', 'amazon'),
'bucket' => env('AWS_BUCKET'),
'custom_url' => env('STORAGE_CUSTOM_URL'),
],
spatie/laravel-aws (recommended) or manually configure aws/aws-sdk-php-symfony:
AWS_MERGE_CONFIG=true
AWS_REGION=auto
AWS_ENDPOINT=env('AWS_ENDPOINT', null) // For R2
Storage::fake() with a mock client adapter:
Storage::shouldUseMockClient(); // Triggers OneToMany\MockClient
UploadActionInterface.// Before
Storage::disk('s3')->put('avatar.jpg', file_get_contents($path));
// After
$uploadAction->act(new UploadRequest($path, 'jpg', 'users/1/avatar.jpg'));
config('onetomany_storage')..env variables for dynamic overrides.Storage::fake() with the mock client in tests.assertUploadedToMock()).STORAGE_CUSTOM_URL:
if (Str::startsWith($request->url(), config('onetomany_storage.custom_url'))) {
return Storage::disk('s3')->response($key);
}
UploadJob extending ActionInterface and dispatch via Laravel Queue.ParameterBag can be replaced with Laravel’s ArrayConfig for configs.storage events won’t auto-trigger; require manual dispatch in act().local disk.onetomany_storage.yaml.composer.json:
"replace": {
"aws/aws-sdk-php": "3.200",
"fruitcake/laravel-aws": "^2.0"
}
AppServiceProvider.UploadActionInterface.Storage::fake().onetomany_storage.yaml replaces scattered S3 configs in services.Storage::shouldUseMockClient() to phpunit.xml).Storage::url() and custom_url config.StorageDebugger command to dump active client/config.UploadActionInterface calls for auditability.How can I help you explore Laravel packages today?