PHPackages                             rodnaph/edhen - 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. rodnaph/edhen

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

rodnaph/edhen
=============

Encode/Decode EDN

0.16.0(5y ago)7125.0k↓33.3%3PHPPHP &gt;=5.3.3CI failing

Since Dec 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/rodnaph/edhen)[ Packagist](https://packagist.org/packages/rodnaph/edhen)[ RSS](/packages/rodnaph-edhen/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (11)Used By (0)

Encode/Decode EDN in PHP
========================

[](#encodedecode-edn-in-php)

A tool to encode/decode between [EDN](https://github.com/edn-format/edn) and [PHP](http://www.php.net) data structures.

### Note

[](#note)

When converting from EDN to PHP the conversion is lossy as the richness of datatypes supported by EDN is not available in PHP. So a conversion from EDN to PHP and back to EDN would not lose you data, but it would lose type information.

Usage
-----

[](#usage)

The interface is via some static functions on the *Edhen* class. To decode an EDN element...

```
$element = Edhen::decode('(1 :foo [2])');

// array(1, ':foo', array(2))
```

If you have EDN with multiple elements, you can use *decodeAll*

```
$elements = Edhen::decodeAll(':foo :bar :baz');

// array(':foo', ':bar', ':baz')
```

Then for encoding use the *encode* function, passing it the data to encode...

```
$ednString = Edhen::encode(array(1, 2));

// '[1 2]'
```

Data Type Translations
----------------------

[](#data-type-translations)

When decoding EDN to PHP...

EDNPHPnilnulltruetruefalsefalsestringsstringcharactersstringsymbolsstringkeywordsstringintegerintegerfloating-pointdoublelistsarrayvectorsarraymapsarraysetsarray### Builtin Tags

[](#builtin-tags)

EDNPHPinstDateTimeuuidstringWhen encoding PHP to EDN...

PHPEDNnullnilbooleanbooleanintegerintegerdoublefloatarrayvectorarray (assoc)hashmapobjecthashmapresourcenilcallablenilThe decision on if an array is to be converted to a vector or hashmap is done by checking its keys. If any of the keys are non-numeric then a hashmap is used.

EDN is generated as a single string, no pretty-printing is currently supported. Another tool should be used for this.

Custom Tag Handlers
-------------------

[](#custom-tag-handlers)

To implement your own [tag handlers](https://github.com/edn-format/edn#tagged-elements), create a class which implements the [Edhen\\TagHandler](src/Edhen/TagHandler.php)interface and pass it in an array as the second argument to *decode*/*decodeAll*

```
$myHandler = new MyCustomTagHandler();

$element = Edhen::decode($edn, array($myHandler));
```

You can see an [example in the tests](tests/EdhenTest.php#L31).

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

[](#installation)

Edhen can be installed via Composer.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92% 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 ~322 days

Recently: every ~431 days

Total

9

Last Release

1942d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e923c75f23aa7ad12c1d36e6458739d3ed606eb65a481ee26d7b0ac3f9408f17?d=identicon)[rodnaph](/maintainers/rodnaph)

---

Top Contributors

[![rodnaph](https://avatars.githubusercontent.com/u/447579?v=4)](https://github.com/rodnaph "rodnaph (46 commits)")[![adlpz](https://avatars.githubusercontent.com/u/602379?v=4)](https://github.com/adlpz "adlpz (3 commits)")[![owsygavin](https://avatars.githubusercontent.com/u/69899593?v=4)](https://github.com/owsygavin "owsygavin (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rodnaph-edhen/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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