Download the PHP package pixelshaped/flat-mapper-bundle without Composer

On this page you can find all versions of the php package pixelshaped/flat-mapper-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package flat-mapper-bundle

Latest Stable Version CI codecov

Flat Mapper Bundle

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

The Problem

When you write efficient SQL JOINs, you get back flat, denormalized rows where parent data repeats across child records:

But you want clean, nested DTOs for your application:

FlatMapper does this transformation automatically, handling:

And it's fast. FlatMapper outperforms Doctrine entity hydration for read operations—even without N+1 queries. See benchmarks comparing FlatMapper to Doctrine entities, partial objects, and manual mapping.

Quick Start

Installation

Basic Usage

1. Define your DTOs with attributes:

2. Map your flat results:

That's it! You now have properly structured AuthorDTO objects with nested BookDTO arrays.

How It Works

Mapping Attributes

FlatMapper uses PHP attributes to define how flat data maps to your DTOs:

#[Identifier] - Required

Every DTO needs exactly one identifier to track unique instances:

#[Scalar("column_name")] - Optional

Maps a column from your result set to a scalar property. Omit if property names match column names:

#[ReferenceArray(NestedDTO::class)] - For nested objects

Creates an array of nested DTOs from the denormalized data:

#[ScalarArray("column_name")] - For arrays of scalars

Collects scalar values (like IDs) into an array:

#[NameTransformation] - Class-level attribute

Apply consistent naming rules to avoid repeating #[Scalar] on every property:

Individual #[Scalar] or #[Identifier] attributes override class-level transformations.

YAML Mappings

You can also define mappings in YAML (or any PHP array) and FlatMapper will parse them through the same mapping logic as attributes.

If both YAML and PHP attributes are defined for the same DTO/property attribute, PHP attributes take precedence.

YAML attribute arguments support:

Complete Examples

Nested DTOs Example

DTOs:

Input (denormalized):

Output (nested objects):

Scalar Arrays Example

DTO: ScalarArrayDTO

Input:

Output:

Framework Integration

Symfony

FlatMapper works out of the box with Symfony. Optionally configure for better performance:

Doctrine

Use with DQL queries:

Pagination

FlatMapper works with Doctrine's Paginator:

Standalone (No Framework)

Performance Optimization

Mapping Cache

Mapping metadata is created once per DTO and cached across requests when a cache service is configured. The first call analyzes your DTO attributes; subsequent calls use the cached mapping.

Pre-cache Mappings

Avoid creating mappings on hot paths by pre-caching during deployment:

This is optional. Mappings are created automatically when calling map() if not already cached.

Disable Validation in Production

Validation checks ensure your DTOs are configured correctly but add a little overhead. Disable in production:

Or in Symfony:

Why Not Just Use...?

Doctrine Entities

FlatMapper is significantly faster for read operations (see benchmarks):

Using full Doctrine entities for reads also:

FlatMapper gives you lightweight, read-only DTOs optimized for queries.

Doctrine's NEW Operator

Doctrine can create DTOs directly in DQL:

Limitation: Only supports scalar properties. You can't have:

FlatMapper solves this by handling denormalized data at any nesting level.

Other Object Mappers

Most object mappers transform nested arrays (like JSON) to objects:

These don't handle denormalized data where:

PARTIAL Objects + Manual Mapping

You could use Doctrine's PARTIAL objects then map to DTOs, but:

Contributing

Found a bug or have a suggestion? Please open an issue or submit a pull request.

Know of an alternative that solves similar problems? Let us know—we'd love to reference it here!

License

This bundle is released under the MIT License. See the LICENSE file for details.


All versions of flat-mapper-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
symfony/cache-contracts Version ^2.5 || ^3.3
symfony/config Version ^6.1 || ^7.0 || ^8.0
symfony/dependency-injection Version ^6.1 || ^7.0 || ^8.0
symfony/http-kernel Version ^6.1 || ^7.0 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pixelshaped/flat-mapper-bundle contains the following files

Loading the files please wait ...