Download the PHP package uuur86/dalue without Composer
On this page you can find all versions of the php package uuur86/dalue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dalue
Dalue - PHP Data Mapper
The Dalue library provides a powerful, recursive, and memory-efficient method for data mapping and structural transformation in PHP. It allows you to ingest complex, unstructured data sets (like API responses or raw JSON payloads) and map them directly into strict domain models, NoSQL item structures, or specific array formats while optionally mutating the values during the allocation phase.
It eliminates the need for repetitive array traversal, nested loops, and deep conditional type casting in your application layer.
Requirements
- PHP 7.4 or higher (PHP 8.x recommended).
- uuur86/strobj (Automatically installed via Composer).
Installation
You can install the package via Composer:
How It Works
Dalue relies on a defined schema array where you specify the target structure. It supports:
- Dot/Path Notation: Using the
@data/prefix, you can fetch deeply nested values instantly. Use/*wildcard notation to extract columns across array items (e.g.,@data/items/*/sku). - Recursive Array Mapping: You can define nested arrays in your target schema.
- Collection Merging (
[]notation): Automatically resolves and mergeshas_manyrelationships into structured row arrays. - On-the-fly Mutation: Allows passing a callback function to manipulate keys and values (e.g., formatting dates, prefixing keys, casting types) during the mapping loop.
Basic Usage: Transforming a Dataset
Below is a basic example of extracting specific data from a deep array. Use StringObjects::instance() to ingest array or JSON payloads.
Output:
Advanced Usage: Type Casting & Callbacks
You can perform complex transformations by providing a callback function as the third parameter. This is especially useful for formatting strings, rounding floats, or mutating specific fields during mapping.
Real-World Example: Adapting API JSON for AWS DynamoDB
NoSQL databases like AWS DynamoDB require strict type markers (e.g., S for String, N for Number, L for List, M for Map). Dalue cleanly maps complex webhook structures into clean domain models, which can then be formatted into DynamoDB AttributeValue format using AWS SDK's Marshaler.
Scenario:
We receive an e-commerce webhook payload and need to format it for a DynamoDB PutItem operation.
LICENSE
This project is licensed under the GPL-3.0-or-later License. See the LICENSE file for more details.
AUTHOR
Uğur Biçer - @uuur86
CONTRIBUTING
If you want to contribute to this project, you can send pull requests. We expect all contributors to follow our Code of Conduct.
CONTACT
You can contact me via email: [email protected]
BUGS
You can report bugs via GitHub issues.
SECURITY
If you find a security issue, please report it via email: [email protected]
DONATE
If you want to support me, you can donate via GitHub sponsors: https://github.com/sponsors/uuur86
SEE ALSO
- uuur86/strobj - PHP String Objects
- uuur86/wasp - WordPress Advanced Settings Page
- @codeplusdev - Codeplus Development