shureban/laravel-object-mapper
Laravel object mapper maps JSON strings, arrays, and FormRequest data into typed PHP objects (DTOs) using reflection. Use inheritance, a trait, or ObjectMapper directly; supports readonly DTOs and static constructors. Works out of the box via auto-discovery.
Architecture Fit
The laravel-object-mapper package has advanced from v1.2.0 to v2.0.1, a major version release spanning v2.0.0 (breaking) and a v2.0.1 patch. The core value proposition is unchanged: snake_case ↔ camelCase transformation for Laravel applications (API responses, DTOs, Eloquent transformations). The headline change in v2.0.1 is Laravel 13 support (PR #12), signalling the package is actively tracking the Laravel release train. The jump from ^1.2.0 to ^2.0.1 implies the v2.0.0 release introduced breaking changes (not enumerated in the v2.0.1 release notes) that must be reviewed before adopting. Architecturally the fit remains strong — the package still lives in Laravel's service container/facade model — but the v2 API surface should be validated against existing call sites (e.g., ObjectMapper::toCamel(), ObjectMapper::transform(), ObjectMapper::ignore()).
Integration Feasibility Integration remains feasible, but the v1 → v2 upgrade is no longer a drop-in. Because only the v2.0.1 patch notes are provided (Laravel 13 support), the v2.0.0 changelog must be retrieved to identify renamed methods, changed defaults, or dropped config keys. Laravel 13 compatibility is a positive signal for teams on the latest LTS trajectory, but it may also mean v2 drops older Laravel versions (previously cited LTS targets of 8.x/9.x/10.x). Confirmation of the supported Laravel/PHP matrix is required before committing.
Technical Risk
spatie/array-to-object and other overlapping transformation utilities.Key Questions
toCamel()/toSnake()/transform() edge cases (nested arrays, nulls, special characters)?php-ddd/ddd-framework) or API resources (spatie/laravel-api-resources) remain compatible with the v2 API?Stack Fit
composer require shureban/laravel-object-mapper:^2.0.1. Existing installs on ^1.2.0 must be treated as a major upgrade, not a patch bump.Migration Path
ObjectMapper::* call sites and config keys; flag any usage of deprecated/removed APIs.^2.0.1, and run the full transformation test suite (including edge cases from v1).ObjectMapper::toCamel() / toSnake() as renamed or retained).composer.json until v2 is proven in staging; use a feature-flagged adapter class wrapping ObjectMapper so the swap is reversible.Compatibility
spatie/laravel-array-to-object and other array-to-object utilities; API changes in v2 may widen the overlap surface.Sequencing
MapperAdapter around ObjectMapper calls to isolate the upgrade.^2.0.1; observe in staging.^2.0.1 on success.Maintenance
^2.0.1 (not ^2.0.0) to avoid known v2.0.0 issues. Consider ~2.0.1 in conservative services.Support
Str::camel(), custom mappers) as a rollback path for critical paths until v2 is proven.ObjectMapper::transform() in try/catch; log failures with payload shape (not contents) to diagnose edge cases.Scaling
Failure Modes
| Scenario | Mitigation Strategy |
|---|---|
| v2.0.0 breaking changes break existing calls | Retrieve v2.0.0 changelog; grep/gate all ObjectMapper::* call sites behind an adapter. |
| v2 drops Laravel 8/9/10 LTS support | Confirm compatibility matrix before upgrading; defer v2 adoption if on older LTS. |
| PHP version floor raised in v2 | Validate CI matrix; use Docker/Sail for parallel PHP version testing. |
| Transformation behavior changes in edge cases (nested arrays, nulls) | Port v1 test suite verbatim; add new edge-case tests for v2. |
| Package update breaks compatibility | Pin to ^2.0.1; keep ^1.2.0 branch deployable for rollback. |
| Transformation errors in production | Feature-flag swap via adapter class; revert flag if error rate spikes. |
Ramp-Up
toCamel() vs. toSnake() (unchanged conceptually).// API Response Transformation (verify against v2 API)
return ObjectMapper::toCamel($user->toArray());
// Form Request Validation (verify against v2 API)
$data = ObjectMapper::toCamel(request()->all());
How can I help you explore Laravel packages today?