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
Flat Mapper Bundle

Flat Mapper Bundle Laravel Package

pixelshaped/flat-mapper-bundle

Symfony bundle for the Flat Mapper library, enabling fast mapping between flat arrays and PHP objects. Configure mappings with attributes or PHP, then hydrate DTOs from database rows, forms, or API payloads and flatten objects back with minimal boilerplate.

View on GitHub
Deep Wiki
Context7

Object mapper for denormalized data. Transform flat arrays (like database JOIN results) into nested, typed DTOs without the overhead of a full ORM.

Frequently asked questions about Flat Mapper Bundle
Is pixelshaped/flat-mapper-bundle a Laravel package or a Symfony bundle?
It is a Symfony bundle, not a Laravel package. It integrates the pixelshaped/flat-mapper library through Symfony's bundle registration, dependency injection container and configuration system, so mappers are registered as services and can be autowired. There is no Laravel service provider, facade or config file, and dropping it into a Laravel application is not supported out of the box. Treat it as a Symfony-only dependency unless you are prepared to fund an adapter layer.
How do I install and register FlatMapperBundle in a Symfony application?
Install it with Composer using composer require pixelshaped/flat-mapper-bundle. Register the bundle in config/bundles.php for the environments where you need it, which Symfony Flex handles automatically. Bundle configuration lives in config/packages/, where you declare your mappers and mapping strategies. Once registered, the mapper services are available for autowiring without writing manual service definitions.
Which Symfony and PHP versions does FlatMapperBundle support?
The 2.4.0 release notes do not state a supported Symfony or PHP version matrix, so read the package's composer.json constraints before adopting it. Because integration goes through standard bundle registration and the DI container, it should work on maintained Symfony 6.x and 7.x releases, but confirm that rather than assuming it. Pin the constraint in your project and let Composer's solver verify compatibility during the update.
How do I define mappings in YAML with FlatMapperBundle 2.4?
Version 2.4.0 adds YAML mapping as an additional definition format alongside attributes and PHP configuration. The release ships with a minimal changelog entry noting only that YAML mapping was added, and no documented schema or example, so you will likely reverse-engineer the expected structure from the pull request. Start by expressing one simple, well-understood DTO mapping in YAML and diff the resulting behaviour against an equivalent attribute-based mapping. Do not migrate complex mappings until feature parity for nested objects, collections and custom transformers is confirmed.
Can I mix YAML and attribute mappings, and which one takes precedence?
In practice yes: 2.4.0 is an additive minor release, so existing attribute or PHP mappings keep working unchanged and YAML adoption is opt-in per class. However, no precedence rule is documented for the case where YAML and attributes target the same class, so avoid that overlap entirely. Keep each mapped class defined in exactly one format and record that convention in your project docs.
Do YAML mapping files work correctly with the Symfony container and config cache?
Mapping definitions resolved from files can be affected by container and config caching in ways attribute-based mappings are not, so verify behaviour before rollout. Check whether YAML files are compiled into the container cache during warmup and which resource tracking invalidates that cache when a file changes. Test a cache:clear and cache:warmup cycle on staging with an edited mapping file, not just a fresh boot. If invalidation is not tracked automatically, register your mapping directory as an explicit container resource.
Is there a lint command or JSON Schema to validate FlatMapperBundle mapping files?
No validation tooling is described in the 2.4.0 release notes: there is no documented lint command, JSON Schema or mapping-file validator. Treat YAML mapping files as application configuration and validate them yourself, at minimum by parsing them in CI and asserting that the referenced classes and properties exist. A small custom test that loads every mapping and hydrates a fixture DTO catches most malformed-file, tab character and duplicate-key failures early.
How do I autowire and use a Flat Mapper service inside my own Symfony service?
The bundle registers FlatMapper services and their configuration in the container, so you can type-hint the mapper interface in a constructor and let autowiring resolve it. Configure the mapper and its mapping strategy in config/packages/ rather than instantiating it manually. Because the setup is centralized, tests can reuse the same service definition instead of rebuilding a mapper instance per test. If a mapper needs a specific strategy, define a named service and bind it explicitly.
Is upgrading from 2.3.1 to 2.4.0 safe, and how actively is the bundle maintained?
The change is a minor version bump with a single contributor pull request and no deprecation or breaking-change notes, so existing mappings should keep working under semantic versioning. Do check whether the PR pulled in any transitive dependency changes before rolling out. The bundle appears to be a single-maintainer project with a small release cadence, which matters when your mapping layer depends on it: pin your version constraint and keep a fallback plan. Adopt YAML mapping incrementally so any future maintenance gap leaves you with working attribute mappings.
How should I test Flat Mapper mappings in a Symfony application?
Mapping is pure data transformation, so unit tests that hydrate a fixture DTO from a sample database row or API payload give the most value. For YAML mappings, add a test that loads each mapping through the container and asserts the resulting object graph, which also covers file parsing and cache interactions. If you introduce YAML into a codebase that still uses attributes, add a parity test that maps the same input both ways and compares results so drift is caught in CI.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
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