PHPackages                             cuyz/valinor - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cuyz/valinor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cuyz/valinor
============

Dependency free PHP library that helps to map any input into a strongly-typed structure.

2.4.0(1mo ago)1.5k9.2M—8.2%90[27 issues](https://github.com/CuyZ/Valinor/issues)[10 PRs](https://github.com/CuyZ/Valinor/pulls)20MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Nov 28Pushed yesterday14 watchersCompare

[ Source](https://github.com/CuyZ/Valinor)[ Packagist](https://packagist.org/packages/cuyz/valinor)[ Docs](https://github.com/CuyZ/Valinor)[ GitHub Sponsors](https://github.com/romm)[ RSS](/packages/cuyz-valinor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (23)Versions (63)Used By (20)Security (2)

[![Valinor banner](docs/pages/img/valinor-banner.svg)](docs/pages/img/valinor-banner.svg)

— From boring old arrays to shiny typed objects —

[![Latest Stable Version](https://camo.githubusercontent.com/f0114d4ae00aa57b980187291971b46ca54b686e81c1aa73431b8b4b11bf1cd4/68747470733a2f2f706f7365722e707567782e6f72672f6375797a2f76616c696e6f722f76)](https://packagist.org/packages/cuyz/valinor)[![PHP Version Require](https://camo.githubusercontent.com/fde7b53154924c364dad539f764d06f4e8c023d3a1dc16ac9615ea65523282b8/68747470733a2f2f706f7365722e707567782e6f72672f6375797a2f76616c696e6f722f726571756972652f706870)](https://packagist.org/packages/cuyz/valinor)[![Total Downloads](https://camo.githubusercontent.com/375c51dd990396f774e02f185bb850cc9b849b901ba664a43c63911588988000/68747470733a2f2f706f7365722e707567782e6f72672f6375797a2f76616c696e6f722f646f776e6c6f616473)](https://packagist.org/packages/cuyz/valinor)[![Mutation testing badge](https://camo.githubusercontent.com/c8720d1a50bb3e84a66295f6d48311071ce4b8e8c61f2aeed7ce34b7ade4992b/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532464375795a25324656616c696e6f722532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/CuyZ/Valinor/master)

---

Valinor takes care of the construction and validation of raw inputs (JSON, plain arrays, etc.) into objects, ensuring a perfectly valid state. It allows the objects to be used without having to worry about their integrity during the whole application lifecycle.

The validation system will detect any incorrect value and help the developers by providing precise and human-readable error messages.

The mapper can handle native PHP types as well as other advanced types supported by [PHPStan](https://phpstan.org/) and [Psalm](https://psalm.dev/) like shaped arrays, generics, integer ranges and more.

The library also provides a normalization mechanism that can help transform any input into a data format (JSON, CSV, …), while preserving the original structure.

Installation
------------

[](#installation)

```
composer require cuyz/valinor
```

**📔 Read more on the [online documentation](https://valinor-php.dev)**

Example
-------

[](#example)

```
final class Country
{
    public function __construct(
        /** @var non-empty-string */
        public readonly string $name,

        /** @var list */
        public readonly array $cities,
    ) {}
}

final class City
{
    public function __construct(
        /** @var non-empty-string */
        public readonly string $name,

        public readonly DateTimeZone $timeZone,
    ) {}
}

$json = name; // France
    echo $country->cities[0]->name; // Paris
} catch (\CuyZ\Valinor\Mapper\MappingError $error) {
    // Handle the error…
}
```

Documentation
-------------

[](#documentation)

The full documentation is available on [valinor-php.dev](https://valinor-php.dev).

Credits &amp; thank you
-----------------------

[](#credits--thank-you)

The development of this library is mainly motivated by the kind words and the help of many people. I am grateful to everyone, especially to the contributors of this repository who directly help to push the project forward:

[![](https://camo.githubusercontent.com/669108642df67e14c81ca0491a2e9f1bd754df71d7470f7c9a299a442c30aaf9/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d6375797a2f76616c696e6f72)](https://github.com/cuyz/valinor/graphs/contributors)

### Powered by

[](#powered-by)

[![PhpStorm logo](https://camo.githubusercontent.com/1e31d98d23a59aa7fddbdae1155126adeac9ad6cded9a478fc8c5d377942c433/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f50687053746f726d2e737667)](https://jb.gg/OpenSourceSupport)

I have to give [JetBrains](https://www.jetbrains.com/) credits for providing [a free PhpStorm license](https://jb.gg/OpenSourceSupport) for the development of this open-source package.

### Special thanks

[](#special-thanks)

I also want to thank [![blackfire-logo](docs/pages/img/blackfire-logo.svg "Blackfire logo") Blackfire](https://www.blackfire.io/?utm_source=valinor&utm_medium=readme&utm_campaign=free-open-source)for providing a license of their awesome tool, leading to notable performance gains when using this library.

###  Health Score

77

—

ExcellentBetter than 100% of packages

Maintenance95

Actively maintained with recent releases

Popularity72

Solid adoption and visibility

Community48

Growing community involvement

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 82.4% 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.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~40 days

Total

59

Last Release

56d ago

Major Versions

0.17.0 → 1.0.02022-11-27

0.17.1 → 1.3.02023-02-08

1.x-dev → 2.0.02025-06-27

PHP version history (8 changes)0.1.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0

0.16.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0

1.0.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0

1.6.0PHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

1.10.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

1.14.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

2.3.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

2.3.2PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6a68d1d1332665e5173e7702415c77bcedf41521bbc540cad7429a1230c941e4?d=identicon)[Romm](/maintainers/Romm)

---

Top Contributors

[![romm](https://avatars.githubusercontent.com/u/6342901?v=4)](https://github.com/romm "romm (509 commits)")[![TimWolla](https://avatars.githubusercontent.com/u/209270?v=4)](https://github.com/TimWolla "TimWolla (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![Ocramius](https://avatars.githubusercontent.com/u/154256?v=4)](https://github.com/Ocramius "Ocramius (8 commits)")[![danog](https://avatars.githubusercontent.com/u/7339644?v=4)](https://github.com/danog "danog (7 commits)")[![Mopolo](https://avatars.githubusercontent.com/u/1319234?v=4)](https://github.com/Mopolo "Mopolo (7 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (6 commits)")[![NanoSector](https://avatars.githubusercontent.com/u/1280380?v=4)](https://github.com/NanoSector "NanoSector (5 commits)")[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (5 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (5 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (5 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (3 commits)")[![boesing](https://avatars.githubusercontent.com/u/2189546?v=4)](https://github.com/boesing "boesing (3 commits)")[![robchett](https://avatars.githubusercontent.com/u/5231691?v=4)](https://github.com/robchett "robchett (2 commits)")[![mtouellette](https://avatars.githubusercontent.com/u/77415006?v=4)](https://github.com/mtouellette "mtouellette (2 commits)")[![sovrin](https://avatars.githubusercontent.com/u/11853025?v=4)](https://github.com/sovrin "sovrin (2 commits)")[![sukei](https://avatars.githubusercontent.com/u/890645?v=4)](https://github.com/sukei "sukei (2 commits)")[![thePanz](https://avatars.githubusercontent.com/u/226021?v=4)](https://github.com/thePanz "thePanz (2 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (2 commits)")[![nickvergessen](https://avatars.githubusercontent.com/u/213943?v=4)](https://github.com/nickvergessen "nickvergessen (2 commits)")

---

Tags

jsonarrayyamlconversionobjecttreemappingmapperhydrator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cuyz-valinor/health.svg)

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

###  Alternatives

[orisai/object-mapper

Raw data mapping to validated objects

1133.5k2](/packages/orisai-object-mapper)[jasny/dotkey

Dot notation access for objects and arrays

14219.5k6](/packages/jasny-dotkey)[selective/transformer

A strictly typed array transformer with dot-access, fluent interface and filters.

3817.8k1](/packages/selective-transformer)

PHPackages © 2026

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