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

Marshaller Laravel Package

gnugat/marshaller

gnugat/marshaller is a small, framework-agnostic PHP library for marshalling data: it converts arrays into objects and objects back into arrays through configurable builders and extractors, making it easy to map raw input to domain objects in any project.

View on GitHub
Deep Wiki
Context7

[DEPRECATED] A PHP library that converts from one format to another.

Frequently asked questions about Marshaller
What is gnugat/marshaller used for in Laravel applications?
gnugat/marshaller is a lightweight, framework-agnostic PHP library for converting structured data such as arrays into typed objects and converting those objects back into arrays or other formats. In Laravel projects it is useful at API, webhook, persistence, export, and event-data boundaries where raw input must become domain objects without putting serialization logic in the model. It is Composer-installable and does not require Laravel-specific integration.
How do I install gnugat/marshaller with Composer?
Install it with Composer using composer require gnugat/marshaller, then verify the resolved version and PHP constraints in your application. Because the library is framework-agnostic, there is no Laravel service provider or facade to register. Commit the lockfile change and run your existing test suite before using it in production code.
Does gnugat/marshaller support my Laravel and PHP version?
The package is framework-agnostic and Composer-installable, so Laravel compatibility depends on your application's PHP version and the package's declared Composer constraints rather than a Laravel-specific release matrix. Check the package composer.json, changelog, and repository maintenance activity, then run your Laravel test suite after upgrading. For the v1.1.0 collection feature, validate that your custom MarshallerStrategy implementations still behave correctly for single objects and collections.
How does collection marshalling work in gnugat/marshaller v1.1.0?
In v1.1.0, Marshaller can iterate a collection and invoke the appropriate MarshallerStrategy for each element, reducing custom map and loop code. Before relying on it, confirm which collection types are supported, how strategies are resolved, whether nested collections are recursed, how exceptions are handled, and whether keys and collection return types are preserved. It is best introduced as an opt-in capability in one service or transformer first.
Can gnugat/marshaller handle nested objects and collections?
The package is designed to handle nested objects and collections, and the v1.1.0 release extends collection-aware marshalling. Test nested collection cases explicitly because strategy resolution, recursion depth, key preservation, and exception behavior can vary by structure. Keep the mapping rules documented so nested transformations remain predictable.
How do I configure custom mapping and conversion rules?
Custom mapping is handled through configurable builders, extractors, and MarshallerStrategy implementations rather than hard-coding conversion logic in domain models. Define the strategy that applies to each object or element type and keep the transformation rules centralized. For collection marshalling, document which strategies apply to which element types and how unsupported elements should behave.
How do I unmarshal objects back into arrays?
Unmarshalling converts objects back into arrays or other formats through extractors, keeping serialization concerns outside your domain code. Configure the extractor to match the output shape your API, persistence layer, or export process expects. Add tests for nested objects and collections so the extracted structure stays stable.
How should I test gnugat/marshaller in a Laravel app?
Add contract tests for single-object marshalling, empty collections, nested collections, unsupported element types, strategy exceptions, key preservation, and the expected return type. Run those tests after the Composer minor-version upgrade and before expanding usage beyond a pilot transformer. This is especially important if you have custom MarshallerStrategy classes.
What production risks should I check with collection marshalling?
The main production risks are unclear collection support, strategy resolution rules, nested collection behavior, exception handling, key preservation, and memory or performance overhead on large, lazy, or paginated collections. Check whether iteration streams or materializes results and whether failures are fail-fast, partial output, or collected errors. Monitor transformation failures where the package handles external or high-volume payloads.
What alternatives to gnugat/marshaller should I consider for DTO mapping?
Alternatives include Symfony Serializer, JMS Serializer, spatie/laravel-data, Laravel API Resources, or a small custom DTO mapper, depending on how much framework coupling and strategy customization you want. Choose gnugat/marshaller when you want a lightweight, framework-agnostic marshalling abstraction with configurable builders and extractors. Compare collection support, error semantics, and maintenance expectations before adopting.
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.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource