Download the PHP package igorpocta/data-mapper without Composer
On this page you can find all versions of the php package igorpocta/data-mapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download igorpocta/data-mapper
More information about igorpocta/data-mapper
Files in igorpocta/data-mapper
Download igorpocta/data-mapper
More information about igorpocta/data-mapper
Files in igorpocta/data-mapper
Vendor igorpocta
Package data-mapper
Short Description Lightweight PHP library for mapping data to objects and back (e.g. JSON ↔ object).
License MIT
Package data-mapper
Short Description Lightweight PHP library for mapping data to objects and back (e.g. JSON ↔ object).
License MIT
Please rate this library. Is it a good library?
Informations about the package data-mapper
Data Mapper
High-performance and type-safe PHP library for bidirectional data mapping between JSON/arrays/CSV and objects.
Requirements
- PHP 8.1 or higher
- Composer
Installation
The package was previously published as
igorpocta/data-mapper.airora/data-mapperreplaces it (same code, samePocta\DataMappernamespace, continuous versions) - switch the requirement name:
Quick Start
Configuration
See Configuration for all options.
Key Features
Mapping
- Bidirectional mapping: JSON/array/CSV ↔ objects with automatic conversion
- CSV Support: Import/export CSV files with automatic type conversion and custom column mapping
- Batch processing: Efficient mapping of collections with
fromArrayCollection(),toJsonCollection(),fromCsv(), etc. - Property path resolver: Map nested values using dot notation (e.g.,
user.address.street) - Type safety: Typed properties and constructor parameters drive conversion (union types are mapped as
string- set the type explicitly with#[MapProperty(type: ...)])
Data Types
- Basic types: int, float, string, bool, array
- DateTime: DateTimeImmutable and DateTime with formats and timezones
- Enum: BackedEnum and UnitEnum (PHP 8.1+)
- Objects: Nested objects and arrays of objects
Security (untrusted input)
- Strict mode: Unknown keys (typos, extra fields) are rejected, also in nested objects
- Public properties only: No private/protected data in output, no mass assignment from input
- Direction control:
#[Ignore],#[OutputOnly](e.g.role,id),#[InputOnly](e.g.password) - Input shape checks: JSON depth limit,
InvalidInputExceptionfor scalars/lists where an object is expected
Advanced
- Constructor properties: Full support for promoted properties
- Partial updates: Merge partial data into existing objects with
merge() - Object-to-DTO mapping: Map from Doctrine entities to DTOs using
fromObject() - Discriminator mapping: Polymorphic object mapping based on discriminator fields
- Filters: 70+ built-in filters (security, formatting, case conversion, etc.)
- Hydration: Custom functions for data transformation using
MapPropertyWithFunction - Event System: Hooks for pre/post processing (logging, transformations, error handling)
- Validation: 40+ Assert attributes (NotNull, Range, Email, Count, Valid, Callback, etc.)
- Validation Groups: Conditional validation with
GroupSequenceProviderInterface - Recursive Validation:
#[Valid]for nested objects with dot-notation error paths
Code Quality
- PHPStan Level 9: Strictest static analysis, checked on PHP 8.1 - 8.5
- Extensive test suite run on PHP 8.1 - 8.5
- Zero external dependencies
- Debug & Profiling: Integrated tools for performance analysis
Attributes
| Attribute | Purpose |
|---|---|
#[MapProperty] |
Custom key (name), nested path, explicit type, arrayOf, classType |
#[MapDateTimeProperty] |
Input format, outputFormat, timezone for date/time values (plus name/path) |
#[MapFrom] |
Source path/getter for fromObject() (entity → DTO) |
#[MapCsvColumn] |
CSV column by name or index |
#[MapPropertyWithFunction] |
Compute the value with a callable (HydrationMode::VALUE/PARENT/FULL) |
#[DiscriminatorMap] |
Polymorphic mapping by a discriminator field |
#[Ignore] / #[OutputOnly] / #[InputOnly] |
Exclude a property from both directions / from input / from output |
Filters (#[StringTrimFilter], ...) |
Transform values during mapping - see Advanced Features |
Validators (#[NotBlank], #[Valid], ...) |
Validation rules - see Validation |
Documentation
| Topic | Description |
|---|---|
| Configuration | MapperOptions, supported types |
| Usage | Basic usage, batch processing, CSV, merge, Object-to-DTO, discriminator, class definitions |
| Advanced Features | Property paths, filters, hydration, nullable, custom names, type conversion |
| Event System | Event listeners, priorities, practical examples |
| Validation | Validators, groups, recursive validation, callback, custom validators |
| Cache System | Array, File, Redis, custom cache implementations |
| Debug & Profiling | Debugger, profiler, performance analysis |
| Architecture | Custom types, separate components, folder structure, examples |
Testing
License
MIT
All versions of data-mapper with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
The package igorpocta/data-mapper contains the following files
Loading the files please wait ...