Fast Map

FEATURE STATE: Middleware 0.1 [alpha]

Definition of a Mapping

A mapping is an operation that associates each element of a source of data into a new format of the same data. By this operation, it is possible to transform the way the data is represented.

The Abstract Mapping Tree

The abstract mapping tree is a representation of the mapping to apply to your data, in order to transform its representation. It is an internal representation build for a computer to understand how it will have to change the data representation during the mapping operation.

Components included

The php-etl/fast-map component

This component is in charge of representing the Abstract Mapping Tree, and transforming it into compiled PHP code. This compiled PHP code is the actual code that will do the mapping, in an optimized way.

The php-etl/fast-map-config component

This component allows you to configure your mapper according to the type of data you want to input.

If you need to config your mappers, we advise you to use the yml config which will generate a php code usable by the fast-map-config. This code will then be converted into a machine code that can be used by the fast map package.


composer require php-etl/fast-map-plugin


    - field: 'products'
      class: 'Model\\Product'
      expression: 'merge( input["items"], input["shippings"] )'
        - field: 'sku'
          copy: '[sku]'
        - field: 'price'
          expression: 'input["price"]'
          class: 'Model\\Price'
            - field: 'amount'
              expression: 'input["value"]'
            - field: 'currency'
              expression: 'input["currency"]'


use Kiboko\Component\FastMapConfig\CompositeBuilder;
use Kiboko\Component\FastMapConfig\ObjectBuilder;
use Kiboko\Component\FastMap\Compiler;
use Kiboko\Component\FastMap\PropertyAccess\EmptyPropertyPath;
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Model\Product;
use Model\Price;

$mapper = (new ObjectBuilder(Order::class, null, $interpreter))
     ->collection('products', 'merge( input["items"], input["shippings"] )', Product::class)
             ->copy('sku', '[sku]')
             ->object('price', 'input["price"]', Price::class)
                     ->expression('amount', 'input["value"]')
                     ->expression('currency', 'input["currency"]')