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

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

chemaclass/edifact-parser
=========================

An EDIFACT file parser to extract the values from any defined segment

6.4.0(3w ago)164.0k3MITPHPPHP &gt;=8.0CI passing

Since Nov 9Pushed 3w ago3 watchersCompare

[ Source](https://github.com/Chemaclass/edifact-parser)[ Packagist](https://packagist.org/packages/chemaclass/edifact-parser)[ Fund](https://chemaclass.com/sponsor)[ RSS](/packages/chemaclass-edifact-parser/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (16)Versions (24)Used By (0)

📦 EDIFACT Parser
================

[](#-edifact-parser)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ccc585c343794a68da47879dad5b5e20a903ed65ec646aeab4b5eb9cccdccbf9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4368656d61636c6173732f456469666163745061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/Chemaclass/EdifactParser/?branch=main)[![Type Coverage](https://camo.githubusercontent.com/d8f2cb570847ca37640aa73bd1586cecade72c423b6fb5a971953d5aac6bc7e5/68747470733a2f2f73686570686572642e6465762f6769746875622f4368656d61636c6173732f456469666163745061727365722f636f7665726167652e737667)](https://shepherd.dev/github/chemaclass/EdifactParser)[![CI](https://github.com/Chemaclass/EdifactParser/workflows/CI/badge.svg?branch=main)](https://github.com/Chemaclass/EdifactParser/actions)[![PHP Version](https://camo.githubusercontent.com/7f91fd16f805b376c8b9137ddc479aabdc9f79d19807832f85606cb3b74409c4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e302d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)

A complete **PHP toolkit for UN/EDIFACT** — read, write, validate, and stream EDI interchanges with a typed, object-oriented API.

> **EDIFACT** — *Electronic Data Interchange For Administration, Commerce, and Transport* — is the international standard for structured business documents (orders, invoices, despatch advices, transport instructions). 🔍 New to it? [Start here](/docu/README.md).

Why this library
----------------

[](#why-this-library)

- 📥 **Parse** any interchange — unknown tags degrade gracefully to raw values, so no message type is unsupported.
- 📤 **Write** it back — serialize segments to a valid `.edi` string, or assemble a full `UNB…UNZ` interchange with **auto-computed control counts**.
- ✅ **Validate** — pluggable rule sets for required segments, cardinality, and order.
- 🌊 **Stream** — parse multi-gigabyte files in bounded memory (one message at a time).
- 🧱 **Model the full envelope** — interchange → functional groups (`UNG/UNE`) → messages, with duplicate-preserving access and typed metadata on every envelope segment.
- 🏷️ **32 typed segments** out of the box with domain accessors, plus qualifier constants — and trivially [extensible](#-extending) with your own.
- 🔎 **Fluent query API** and a **statistics analyzer** for extracting data.
- 🌍 **Charset-aware** (`UNOA`…`UNOY`), **strictly typed** (PHP 8.0+, PSR-4), and fully covered by PHPUnit, PHPStan, Psalm, Rector and PHP-CS-Fixer.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Parsing](#-parsing) · [Streaming large files](#streaming-large-files)
- [Reading data](#-reading-data) · [Typed accessors](#typed-accessors) · [Query API](#fluent-query-api) · [Line items](#line-items) · [Context hierarchy](#hierarchical-context-segments) · [Envelope metadata](#interchange--envelope-metadata) · [Functional groups](#functional-groups-ungune) · [Statistics](#statistics--analysis) · [Qualifier constants](#qualifier-constants) · [Character sets](#character-sets) · [Built-in segments](#built-in-segments)
- [Writing EDIFACT](#-writing-edifact)
- [Validation](#-validation)
- [Extending](#-extending)
- [Debugging](#-debugging)
- [Development](#-development)
- [Contributing](#-contributing)

---

💾 Installation
--------------

[](#-installation)

```
composer require chemaclass/edifact-parser
```

Requires PHP 8.0+ with `ext-json` and `ext-mbstring`.

---

🚀 Quick Start
-------------

[](#-quick-start)

```
