simple-bus/jms-serializer-bundle-bridge
Symfony bundle that wires SimpleBus’s JMS Serializer ObjectSerializer as the default object serializer for SimpleBus AsynchronousBundle. Enable SimpleBusJMSSerializerBundleBridgeBundle in your AppKernel to use it.
AppKernel, requiring a custom integration path (e.g., service provider, package wrapper).json_encode()). A hybrid approach (e.g., conditional serialization) could mitigate this.spatie/laravel-data or nesbot/carbon could inspire how to wrap JMSSerializer for Laravel.MessageSerializer) to abstract the bridge, allowing swapping implementations (e.g., JSON fallback).| Risk Area | Mitigation Strategy |
|---|---|
| Symfony Dependency | Use a minimal Symfony/HTTP-Kernel polyfill or extract only the serializer logic. |
| Performance Overhead | Benchmark JMSSerializer vs. Laravel’s native JSON for critical paths (e.g., high-throughput queues). |
| Breaking Changes | Pin to a stable JMSSerializer version and test against Laravel’s PHP version (8.0+). |
| Debugging Complexity | Add Laravel-specific logging (e.g., Log::debug()) for serialization failures. |
| Queue Worker Issues | Ensure the bridge works with Laravel’s queue listeners (e.g., HandleJobsMiddleware). |
Why JMSSerializer Over Native JSON?
Queue System Compatibility
Illuminate\Queue\Worker)?Maintenance Burden
Alternatives
spatie/fractal or custom JSON strategies achieve similar goals with less friction?laravel-serializable) that already solves this?Illuminate\Events\Dispatcher’s JSON serialization with JMSSerializer for complex payloads.Illuminate\Bus\Queueable) using JMSSerializer.Fractal or Transformers).EventDispatcher integration won’t directly apply.@Groups may conflict with Laravel Eloquent’s Hidden/Visible attributes.Phase 1: Proof of Concept
laravel-jms-serializer-bridge) that:
SimpleBus/JMSSerializerBridge without Symfony dependencies.Phase 2: Core Integration
Illuminate\Bus\Queueable (job payloads).Illuminate\Events\Dispatcher (event payloads).Phase 3: Full Adoption
Illuminate\Http\JsonResponse).@JMS\Type, @JMS\ExclusionPolicy).| Component | Compatibility Notes |
|---|---|
| Laravel Queues | Works if queue drivers (Redis, database) support custom serialization. |
| Laravel Events | Requires modifying Illuminate\Events\Dispatcher or using a decorator pattern. |
| Laravel Eloquent | May need custom accessors/mutators to handle JMSSerializer annotations. |
| API Resources | Can replace spatie/fractal for complex DTOs. |
| Third-Party Packages | Risk of conflicts with packages using json_encode() (e.g., laravel-cors). |
SerializablePayload) to avoid monolithic changes.spatie/fractal).json_encode() calls across the codebase.@Type, @Groups) and metadata.@MaxDepth, @VirtualProperty).jms/serializer-bundle:compile).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Serialization Errors | Queue jobs fail silently. | Add retry logic with JSON fallback. |
| **Deserialization Fail |
How can I help you explore Laravel packages today?