PHPackages                             rangelreale/mdh - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. rangelreale/mdh

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

rangelreale/mdh
===============

PHP Multiple Data Handler - configurable data parser and formatter to and from PHP format

016PHP

Since Apr 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/RangelReale/mdh)[ Packagist](https://packagist.org/packages/rangelreale/mdh)[ RSS](/packages/rangelreale-mdh/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Multi Data Handler
======================

[](#php-multi-data-handler)

PHP Multi Data Handler (MDH) is a library used to format and parse data **to and from PHP format**. Using multiple converters, is is possible to convert between formats.

The library is very flexible, allowing datatype registration, fallback to a default conversion, and overriding any conversion.

Date and time values are **always** returned as a DateTime class. The library accepts timestamps as input, but the output is always a DateTime class.

### Usage

[](#usage)

```
// creates the base class (the converters "default" and "user" are default)
$mdh = new \RangelReale\mdh\MDH();
// use the en-US locale
$mdh->locale = 'en-US';
// add a mysql converter
$mdh->setConverter('db', new \RangelReale\mdh\mysql\MySQLConverter($mdh));

// using the "db" converter, format a datetime from PHP format to MySQL format
echo $mdh->db->format('datetime', time()), ''; // 2016-12-09 13:26:42
// using the "db" converter, parse a datetime from MySQL format to PHP format
echo print_r($mdh->db->parse('datetime', '2016-01-10 15:00:00'), true), ''; // DateTime Object ( [date] => 2016-01-10 15:00:00.000000 [timezone_type] => 3 [timezone] => America/Sao_Paulo )

// using the "user" converter, format a datetime from PHP format to user format (using locale)
echo $mdh->user->format('datetime', time()), ''; // 12/9/16, 1:34 PM

// convert a datetime value from "db" to "user" format
echo $mdh->convert('db', 'user', 'datetime', '2016-10-10 21:00:00'), ''; // 10/10/16, 9:00 PM
```

### Multiple conversion

[](#multiple-conversion)

Multiple fields can be converted at the same time.

```
$multi = new \RangelReale\mdh\MultiConversion([
    'value' => 'decimal',
    'date_created' => 'datetime',
]);
echo print_r($mdh->convertMulti(null, 'user', $multi, [
    'value' => 15.1872,
    'date_created' => time(),
])->result, true), ''; // Array ( [value] => 15.19 [date_created] => 12/9/16, 1:39 PM )
```

### Default data types

[](#default-data-types)

- raw
- text
- boolean
- integer
- date
- time
- datetime
- decimal
- currency
- decimalfull
- bytes
- timeperiod
- bitmask

### Author

[](#author)

Rangel Reale

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/369785?v=4)[Rangel Reale](/maintainers/RangelReale)[@RangelReale](https://github.com/RangelReale)

---

Top Contributors

[![RangelReale](https://avatars.githubusercontent.com/u/369785?v=4)](https://github.com/RangelReale "RangelReale (28 commits)")

### Embed Badge

![Health badge](/badges/rangelreale-mdh/health.svg)

```
[![Health](https://phpackages.com/badges/rangelreale-mdh/health.svg)](https://phpackages.com/packages/rangelreale-mdh)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19037.7M41](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9642.0k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46143.1k6](/packages/jstewmc-rtf)[moonshine/layouts-field

Field for repeating groups of fields for MoonShine

107.9k](/packages/moonshine-layouts-field)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

112.9k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
