avtonom/media-storage-client-bundle
Pros:
prePersist, preUpdate) for automatic file uploads, reducing boilerplate in business logic.ProxyMediaInterface to abstract remote media, enabling lazy-loading and transparent access to stored files.Cons:
Laravel Compatibility:
symfony/http-client or symfony/process to call the remote SonataMediaBundle API directly, bypassing the bundle entirely.Key Dependencies:
symfony/http-client in modern Symfony; Laravel uses Guzzle/Psr18 clients.spatie/laravel-doctrine-orm)..env) would need rewrites..env or Vault.auth:api or Sanctum would need integration.Why SonataMediaBundle?
Laravel-Specific Needs:
prePersist) translate to Laravel Observers? Are there Eloquent models with similar lifecycle hooks?x-editable) integrate with Laravel Blade? Will frontend libraries (e.g., Dropzone, Uppy) replace them?Performance and Reliability:
Team Expertise:
Alternatives:
Storage facade (with S3/FTP drivers) or packages like spatie/laravel-medialibrary replace this functionality?Laravel Compatibility Matrix:
| Component | Laravel Equivalent | Integration Notes |
|---|---|---|
| Symfony DI | Laravel Service Container | Use bind() or extend() to mock Symfony services (e.g., HttpClient). |
| Doctrine Listeners | Eloquent Observers/Events | Replace prePersist with creating or saved events in Eloquent models. |
| SensioBuzzBundle | Guzzle HTTP Client | Replace Buzz with GuzzleHttp\Client for API calls. |
| Twig Templates | Blade Templates | Rewrite Twig logic to Blade; replace x-editable with Laravel-compatible JS. |
| MonologBundle | Laravel Log Facade | Configure Monolog via config/logging.php; no bundle needed. |
| SonataMediaBundle API | Custom API Client | Use Guzzle to call /api/media/referencefull directly. |
Recommended Architecture:
/api/providers/sonata.media.provider.url/media.MediaStorageClient class that wraps Guzzle calls and integrates with Eloquent.Assessment Phase:
/app_dev.php/api/media/referencefull) and their expected payloads.Proof of Concept (PoC):
Incremental Replacement:
Tooling:
blueimp-file-upload).x-editable with Laravel-compatible libraries like Summernote or custom Blade components.| Symfony Concept | Laravel Equivalent | Example Migration |
|---|---|---|
AvtonomMediaStorageClientBundle |
Custom Laravel Service/Facade | php artisan make:service MediaStorageClient |
ObjectAddFileListener |
Eloquent Observer | Model::observe(MediaUploadObserver::class) |
parameters.yaml |
.env + config/services.php |
Move base_url to .env, bind to container in config/services.php. |
Twig {% javascripts %} |
Blade @stack + Mix/Vite |
Replace with @vite(['resources/js/app.js']) and manual script tags. |
| SonataMediaBundle API | Guzzle HTTP Client | $client = new Client(['base_uri' => env('SONATA_API_URL')]); |
How can I help you explore Laravel packages today?