PHPackages                             dbrkls/edifact - 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. dbrkls/edifact

ActiveLibrary

dbrkls/edifact
==============

Tools in PHP for UN/EDIFACT

1637PHP

Since Apr 18Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

edifact
=======

[](#edifact)

Tools to process EDI messages in UN/EDIFACT format

Supported syntax is version 3.

It's provided in a Composer package:

`composer require sabas/edifact`

The mapping xml files are provided in a separate repository (). To get them within the repository remember to clone with the `--recursive` flag, or download them with `git submodule update --init --recursive`

EDI/Parser
----------

[](#ediparser)

Given an edi message checks the syntax, outputs errors and returns the message as a multidimensional array.

**INPUT**

```
$c = new Parser($x);
```

Where `$x` could be:

- a url
- a string (wrapped message)
- an array of strings (a segment per entry)

OR

```
$c = new Parser();
$c->load($file);
$c->loadString($string);
```

**OUTPUT**

Errors

```
$c->errors();
```

Array

```
$c->get();
```

EDI/Encoder
-----------

[](#ediencoder)

Given a multidimensional array (formatted as the output of the parser), returns an EDI string, optionally one segment per line.

**INPUT**

```
$c = new Encoder($x, $wrap = true);
```

`$x` is a multidimensional array where first dimension is the EDI segment, second contains elements:

- single value
- array (representing composite elements)

`$wrap` is a boolean, if you need a segment per line. Set to false to disable wrapping

OR

```
$c = new Encoder();
$c->encode($array, $wrap);
```

**OUTPUT**

```
$c->get(); // returns String
```

EDI/Analyser
------------

[](#edianalyser)

Create from EDI file readable structured text with comments from `segments.xml`.

**INPUT**

```
$analyser = new EDI\Analyser();
$analyser->loadSegmentsXml('edifact/src/EDI/Mapping/d95b/segments.xml');
```

- `$url` is the path to orginal EDI message file
- `$parsed` is a by `EDI\Parser()` created EDI messages array

**TEXT OUTPUT**

```
$analyser->process($parsed); // returns text
```

Or

```
$analyser->process($parsed, $rawSegments);
```

- `$rawSegments` (optional) is segments in raw format from `EDI\Parser::getRawSegments` to be printed before each segment in the analysed result

**JSON OUTPUT**Get a json representation of the array, with the element names as key.

```
$analyser->process($parsed);
$json = $analyser->getJson();
```

EDI/Reader
----------

[](#edireader)

Read from EDI file requested segment element values.

**INPUT**

```
$r = new Reader($x);
$sender = $r->readEdiDataValue('UNB', 2);
$Dt = $r->readUNBDateTimeOfPpreperation();
```

Where X could be:

- a url
- a string (wrapped message)
- an array of strings (a segment per entry)

OR

```
$c = new Parser($x);

$r=new Reader();
$r->setParsedFile($c);
$sender = $r->readEdiDataValue('UNB', 2);
$Dt = $r->readUNBDateTimeOfPpreperation();
```

**OUTPUT**Errors

```
$c->errors();
```

Array

```
$c->get();
```

EDI/Interpreter
---------------

[](#ediinterpreter)

Organizes the data parsed by EDI/Parser using the xml description of the message and the xml segments.

**INPUT**

```
$p=new EDI\Parser($edifile);
$edi = $p->get();

$analyser = new EDI\Analyser();
$segs =$analyser->loadSegmentsXml('vendor/sabas/edifact-data/D95B/segments.xml');

$interpreter = new EDI\Interpreter('vendor/sabas/edifact-data/D95B/messages/codeco.xml', $segs);
$prep = $interpreter->prepare($edi);
```

**OUTPUT**

Json

```
$interpreter->getJson()
```

Errors (per message)

```
$interpreter->getErrors()
```

Example
-------

[](#example)

**Edifact**

`DTM+7:201309200717:203'`

**Array**

```
['DTM',['7','201309200717','203']]
```

Syntax data
-----------

[](#syntax-data)

Processed from EDI PEAR Package by David JEAN LOUIS (izi), downloadable from [https://code.google.com/p/izi-sandbox/source/browse/trunk/php/php\_edi/](IZISandbox).

Notes
-----

[](#notes)

Valid characters are: A-Za-z0-9.,-()/'+:=?!"%&amp;\*;&lt;&gt; [UNECE](http://www.unece.org/trade/untdid/texts/d422_d.htm#p5.1)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.9% 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://www.gravatar.com/avatar/542187ba859514d10d0952dca77df8ea889a9651b249d0b5b513da791fd2919b?d=identicon)[uldisn](/maintainers/uldisn)

---

Top Contributors

[![sabas](https://avatars.githubusercontent.com/u/1304918?v=4)](https://github.com/sabas "sabas (66 commits)")[![uldisn](https://avatars.githubusercontent.com/u/3525344?v=4)](https://github.com/uldisn "uldisn (30 commits)")[![emilv](https://avatars.githubusercontent.com/u/1684914?v=4)](https://github.com/emilv "emilv (9 commits)")[![Xiro](https://avatars.githubusercontent.com/u/1381970?v=4)](https://github.com/Xiro "Xiro (2 commits)")[![lazytyper](https://avatars.githubusercontent.com/u/5507298?v=4)](https://github.com/lazytyper "lazytyper (1 commits)")[![repat](https://avatars.githubusercontent.com/u/516807?v=4)](https://github.com/repat "repat (1 commits)")[![KillerKent](https://avatars.githubusercontent.com/u/18664587?v=4)](https://github.com/KillerKent "KillerKent (1 commits)")[![jbrooksuk](https://avatars.githubusercontent.com/u/246103?v=4)](https://github.com/jbrooksuk "jbrooksuk (1 commits)")[![gRoberts84](https://avatars.githubusercontent.com/u/348184?v=4)](https://github.com/gRoberts84 "gRoberts84 (1 commits)")

### Embed Badge

![Health badge](/badges/dbrkls-edifact/health.svg)

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

PHPackages © 2026

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