Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Package

Laravel Package Laravel Package

json-mapper/laravel-package

Map JSON payloads and arrays into typed PHP objects and DTOs with this Laravel package. A fluent API defines field mappings, nested structures, and collections, with clean integration into Laravel's container, facades, and config.

View on GitHub
Deep Wiki
Context7

The JsonMapper package for Laravel

Frequently asked questions about Laravel Package
What does json-mapper/laravel-package actually do?
It is a Laravel integration package for the framework-agnostic json-mapper/json-mapper core. You define mapping classes that describe how JSON response keys correspond to typed PHP properties, and the mapper hydrates nested objects and collections with minimal boilerplate. The Laravel package itself is a thin wrapper: service provider registration, a JsonMapperInterface container binding, publishable config for the middleware stack, and a facade.
Which Laravel versions does json-mapper/laravel-package 3.0.0 support?
The 3.0.0 release notes contradict themselves: one line says support for Laravel 8, 9, and 10 was restored, while another says support for Laravel 5.5 through 10 was dropped and the minimum is now Laravel 11. The stated PHP floor of 7.4 also conflicts with a Laravel 11 requirement, since Laravel 11 needs PHP 8.2. Read composer.json directly for the literal illuminate/support constraint and check what the CI matrix actually tests before you upgrade.
How do I install json-mapper/laravel-package in a Laravel app?
Install it with Composer using composer require json-mapper/laravel-package. On supported Laravel versions the service provider and facade are registered through package auto-discovery, so you normally do not need to add them to your provider list manually. Verify that the version constraint resolves against your PHP and Laravel versions first, because 3.0.0 is a breaking major with an unclear compatibility surface.
Do I need to publish the config file for json-mapper/laravel-package?
Publishing is optional; the package works with its default configuration, which covers things like the middleware stack. Publish it only if you need to change those defaults, using the vendor:publish command for the package's config tag. After upgrading to 3.0.0, re-check your published config for changed keys or defaults rather than assuming it still matches.
How do I map nested JSON objects and collections with json-mapper?
You describe the relationship in your mapping classes, pointing a property at another mapping class instead of writing manual recursion. The package supports nested objects, arrays, and collections, so a list of child payloads hydrates into a typed collection rather than a raw array. This is the main reason to use it over hand-rolled hydration inside controllers and services.
Can json-mapper cast dates and value objects?
Yes. The package supports custom casters and transformers, which is how you convert date strings and value objects instead of leaving them as raw scalars. You register the caster or transformer and reference it from the mapping definition. That keeps conversion logic out of your controllers and services.
How do I resolve the mapper in a Laravel controller or service?
The service provider binds JsonMapperInterface in Laravel's container, so you can type-hint the interface in controllers, services, and jobs. A facade is also available if you prefer static-style access, but injecting the interface keeps your code easier to swap and test. In tests you can bind a fake implementation, and mapping classes can be exercised directly with fixture arrays or JSON strings without going through HTTP.
Is json-mapper/laravel-package safe to use in production?
Code risk is low: it is a small MIT-licensed integration shell over an actively maintained core, with no queue, route, asset, or migration footprint. Ecosystem risk is higher, since the repository has roughly 25 stars and zero dependents, which means little external validation or crowd-sourced bug discovery. The 3.0.0 release adds release-hygiene risk because its breaking-change notes contradict each other, so verify the real constraints in composer.json before shipping it.
Should I stay on version 2.x if I am on Laravel 8, 9, or 10?
That is the safest default until the 8/9/10 contradiction in the 3.0.0 notes is resolved. Staying on 2.x avoids a major upgrade whose documented compatibility surface cannot be trusted without reading source. The other option is to write a small adapter against the framework-agnostic json-mapper/json-mapper core, which is roughly 20 to 30 lines of service provider and container binding code.
Does json-mapper/laravel-package support Laravel 13?
3.0.0 declares Laravel 13 support, which is a genuine positive signal that the maintainer intends to track framework majors instead of letting the wrapper rot. If Laravel 13 is not yet generally available, that declaration is forward-looking CI wiring rather than a configuration you can run today. Check whether the CI matrix actually tests against it or whether support is only declared in the notes.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections