PHPackages                             bennett-treptow/x12-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. bennett-treptow/x12-parser

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

bennett-treptow/x12-parser
==========================

A library used to parse X12 EDI. Forked from uhin/x12-parser

1.0.10(5y ago)0721MITPHPPHP &gt;=7.0

Since Jun 28Pushed 5y agoCompare

[ Source](https://github.com/bennett-treptow/x12-parser-library)[ Packagist](https://packagist.org/packages/bennett-treptow/x12-parser)[ RSS](/packages/bennett-treptow-x12-parser/feed)WikiDiscussions master Synced today

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

X12 Parser / Serializer
=======================

[](#x12-parser--serializer)

### Releases

[](#releases)

##### 1.0.0

[](#100)

- Initial release
- Basic parsing and serializing of X12
- EDI is stored in hierarchical data structure

### Including this library

[](#including-this-library)

You'll need to include this library in your project in order to use it. First, add the following to the repositories section of your composer.json file:

```
{
  ...
  "require": {
    ...
    "uhin/x12-parser": "1.0.0"
    ...
  }
}
```

You can now include the library into your project by running:

```
composer require uhin/x12-parser:1.0.0
```

Once you're included the library in your project, you can now begin writing code to parse and serialize X12 EDI.

### Examples

[](#examples)

##### Parsing a file

[](#parsing-a-file)

```
use Uhin\X12Parser\Parser\X12Parser;

// Load the file into memory
$rawX12 = file_get_contents('path-to-your-file');

// Create a parser object
$parser = new X12Parser($rawX12);

// Parse the file into an object data structure
$x12 = $parser->parse();
// $x12 is now an X12 object containing all of the information from the X12 file
```

##### Accessing/Modifying data in the X12

[](#accessingmodifying-data-in-the-x12)

Note: If any segment/property can have multiples then it will always be parsed into an array, even if there is only one present. This is to avoid confusion on whether or not you are dealing with an array or an object.

```
// Using the $x12 object from the examlpe above...

// Retrieving the GS06
$gs06 = $x12->ISA[0]->GS[0]->GS06;

// Setting the GS06 value
$x12->ISA[0]->GS[0]->GS06 = 'Changed Value';
```

##### Converting a parsed file back to X12

[](#converting-a-parsed-file-back-to-x12)

```
use Uhin\X12Parser\Serializer\X12Serializer;

// Using the $x12 object from the examlpe above...
$serializer = new X12Serializer($x12);

// Options for serializing:
$serializer->addNewLineAfterSegment(true);
$serializer->addNewLineAfterIEA(true);

// Generate the raw X12 string
$rawX12 = $serializer->serialize();
```

### Unit Tests

[](#unit-tests)

First, make sure that you've placed your test files in the `tests/test-files` directory.

**NOTE:** *Don't commit these files to git if they have any HIPPA data.*

The current tests will look for the following files in the `tests/test-files` directory:

- `277.txt`
- `835.txt`
- `837.txt`
- `999.txt`
- `TA1.txt`

Once you have your files in place, you can run this command from the root of the library:

```
./vendor/bin/phpunit --bootstrap ./vendor/autoload.php --testdox tests
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 52.8% 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 ~75 days

Recently: every ~121 days

Total

11

Last Release

2172d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/42162376?v=4)[Ben Treptow](/maintainers/btreptow)[@btreptow](https://github.com/btreptow)

---

Top Contributors

[![cameronhejazifar](https://avatars.githubusercontent.com/u/72213537?v=4)](https://github.com/cameronhejazifar "cameronhejazifar (19 commits)")[![zlobato](https://avatars.githubusercontent.com/u/30511504?v=4)](https://github.com/zlobato "zlobato (7 commits)")[![behrhartuhin](https://avatars.githubusercontent.com/u/30664560?v=4)](https://github.com/behrhartuhin "behrhartuhin (2 commits)")[![bennett-treptow](https://avatars.githubusercontent.com/u/4967100?v=4)](https://github.com/bennett-treptow "bennett-treptow (2 commits)")[![rmclellanduhin](https://avatars.githubusercontent.com/u/36676665?v=4)](https://github.com/rmclellanduhin "rmclellanduhin (2 commits)")[![markguyver](https://avatars.githubusercontent.com/u/3242128?v=4)](https://github.com/markguyver "markguyver (1 commits)")[![chejaziuhin](https://avatars.githubusercontent.com/u/36676697?v=4)](https://github.com/chejaziuhin "chejaziuhin (1 commits)")[![skiram](https://avatars.githubusercontent.com/u/3024449?v=4)](https://github.com/skiram "skiram (1 commits)")[![kclayton925](https://avatars.githubusercontent.com/u/11861818?v=4)](https://github.com/kclayton925 "kclayton925 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bennett-treptow-x12-parser/health.svg)

```
[![Health](https://phpackages.com/badges/bennett-treptow-x12-parser/health.svg)](https://phpackages.com/packages/bennett-treptow-x12-parser)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/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.

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

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

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

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

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

PHPackages © 2026

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