Download the PHP package elaitech/data-mapper without Composer

On this page you can find all versions of the php package elaitech/data-mapper. 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 data-mapper

๐Ÿ“ฆ Elaitech DataMapper

A reusable data mapping and transformation library for Laravel 12. Maps source fields to target fields with chained value transformers, dot-notation and wildcard field extraction, value mapping lookups, and full support for both associative and indexed (header-based) data rows.

Namespace: Elaitechx\DataMapper
Requires: PHP 8.4+ ยท Laravel 12 ยท spatie/laravel-data ^4.19


๐Ÿ“– Table of Contents


๐Ÿš€ Installation

As a local Composer package

In your root composer.json, add the package as a path repository:

Then install:

The DataMapperServiceProvider is auto-discovered by Laravel. It registers:


๐Ÿ— Architecture


โšก Quick Start


๐Ÿงฉ Core Components

DataMapperService

The main service class. Implements DataMapperInterface.

Behaviour:

FieldExtractor

Extracts values from data using:

Pattern Example Description
Direct access name Top-level field
Dot notation address.city Nested field traversal
Wildcard items.*.name Extract from all array elements

ValueTransformer

The transformer registry and execution engine. Manages all registered transformers and applies transformation chains.

Transformation flow:

  1. Check if value is empty โ†’ return defaultValue (unless it's an array transformer)
  2. Apply value mapping if configured (lookup table)
  3. Apply transformer (type conversion, formatting)
  4. If result is empty string and defaultValue is set โ†’ return defaultValue

๐Ÿ”ง Built-in Transformers

Name Label Description Requires Format
none None Pass-through, no transformation โŒ
trim Trim Remove leading/trailing whitespace โŒ
upper Uppercase Convert to UPPERCASE โŒ
lower Lowercase Convert to lowercase โŒ
int Integer Cast to int (extracts digits from messy strings; falls back to default) โŒ
float Float Cast to float with precision control โœ… (decimals)
bool Boolean Cast to bool (handles "true", "1", "yes", etc.) โŒ
date Date Parse and reformat dates โœ… (date format)
array_first Array First Extract first element from array โŒ
array_join Array Join Join array elements with separator โœ… (separator)

๐Ÿ—บ Field Extraction

Dot Notation

Access nested fields in associative arrays:

Wildcard Notation

Extract values from arrays of objects:

Indexed (Header-Based) Rows

For data without keys (e.g., CSV rows), provide headers:


๐Ÿ”€ Value Mapping

Map specific values using a lookup table. Useful for code-to-label conversions:

Value mapping is applied before the transformer, so you can combine both:


๐Ÿ›  Creating Custom Transformers

Implement the TransformerInterface:

Register it:

Or register in a service provider for global availability:


๐Ÿ“‹ DTOs

MappingConfigurationData

Input to the mapper:

Property Type Description
data array Array of rows to map
mappingRules DataCollection<MappingRuleData> Mapping rules to apply
headers ?array Column headers for indexed rows

MappingRuleData

A single field mapping rule:

Property Type Default Description
sourceField string โ€” Source field name (supports dot/wildcard notation)
targetField string โ€” Target field name in output
transformation string 'none' Transformer name to apply
isRequired bool false Throw if source field is missing
defaultValue mixed null Fallback for empty values
format ?string null Format parameter for transformers (e.g., date format)
valueMapping ?array null Value lookup table ([['from' => ..., 'to' => ...]])

DataMappingResultData

Output from the mapper:

Property Type Description
data array Successfully mapped rows
errors array Per-row error messages

๐Ÿ“œ Contracts

DataMapperInterface

TransformerInterface


๐Ÿงช Testing


๐Ÿ“ฆ Dependencies

Package Version Purpose
illuminate/support ^12.0 Laravel framework support
spatie/laravel-data ^4.19 Typed DTOs with auto-mapping

๐Ÿ“„ License

MIT


All versions of data-mapper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3|^8.4
illuminate/support Version ^12.0|^13.0
spatie/laravel-data Version ^4.19
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 elaitech/data-mapper contains the following files

Loading the files please wait ...