PHPackages                             dominservice/onix-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. dominservice/onix-parser

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

dominservice/onix-parser
========================

An ONIX 3.0 Parser

1.0.1(3y ago)0191MITPHP

Since Jul 31Pushed 3y agoCompare

[ Source](https://github.com/dominservice/onix-parser)[ Packagist](https://packagist.org/packages/dominservice/onix-parser)[ RSS](/packages/dominservice-onix-parser/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

PHP ONIX 3.0 Parser
===================

[](#php-onix-30-parser)

This package is a simple PHP library for reading ONIX 3.0 files in the general formats Short and Ref. Helper functions in the individual units make it easy to read out the details that you need from the data record. Text elements in different formats as well as the different ONIX date formats are automatically parsed and can therefore be used easily.

**This package is currently under development. Although most fields should be detected and parsed by the library, some fields still need more work.**

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

[](#installation)

PHP &gt;=8.1

Installation is recommended to be done via composer by running:

```
composer require dominservice/onix-parser

```

Usage
-----

[](#usage)

To parse an ONIX message in XML format, a new parser is instantiated. The XML file is then passed to the parser. The result is the complete ONIX message that can now be processed.

```
$parser = new \Dso\Onix\Parser();

/** @var Dso\Onix\Message\Message; */
$message = $parser->parseString(
    file_get_contents('sample.xml')
);

/** @var Dso\Onix\Product\Product[] */
$products = $message->getProducts();
```

Code Lists
----------

[](#code-lists)

The library contains all current code lists in **issue 61**. Codes that are specified in the ONIX file are automatically read out, so that you receive a readable version of the codes.

Let's say, you have a product in your message showing a specific NotificationType:

```

        03
        [...]

```

```
// Either get the Code object and read it's code and/or value
$type = $product->getNotificationType();
$code = $code->getCode();   // "03"
$value = $code->getValue(); // "Notification confirmed on publication"

// or directly get the value as string
$value = (string) $product->getNotificationType();
```

### Multi-Language Code Lists

[](#multi-language-code-lists)

According to the website of the official publisher of the ONIX format, the code lists are provided in several languages. The following languages are currently supported:

LanguageLanguage CodeEnglish (default)`en`Spanish`es`German`de`French`fr`Italian`it`Norwegian`nb`Turkish`tr`**Please note that the code lists were automatically scraped from the [EDITEUR website](https://ns.editeur.org/onix/en). Therefore, some translations into the individual languages can be incorrect or partly missing. Feel free to submit a pull request with your fixed language of the code lists.**

To use a specific language, just pass the language code as argument in the parser constructor:

```
// Create parser using german code list values
$parser = new \Dso\Onix\Parser('de');
```

Measurements
------------

[](#measurements)

The PHP ONIX Parser reads all of the given Measurements from the ONIX file and assigns the correct codes for them. Using that, you can either loop through all given Measurements:

```
// get the DescriptiveDetail portion of the product
$descriptiveDetail = $product->getDescriptiveDetail();

foreach ($descriptiveDetail->getMeasures() as $measure) {
	echo sprintf('%s: %s %s',                      // -> "Height: 210 Centimeters"
		(string) $measure->getMeasureType(),       // e.g. "Height"
		$measure->getMeasurement(),                // e.g. "210"
		(string) $measure->getMeasureUnitCode()    // e.g. "Centimeters"
	);
}
```

Using shorthand functions you can also search for measurements of type height, width, thickness or weight:

```
/** @var Dso\Onix\Product\Measure */
$height = $descriptiveDetail->getHeight();
$width = $descriptiveDetail->getWidth();
$thickness = $descriptiveDetail->getThickness();
$weight = $descriptiveDetail->getWeight();

echo sprintf("Height: %s %s", $height->getMeasurement(), $height->getMeasureUnitCode()->getCode());
// --> Height: 210 cm
```

Built With
----------

[](#built-with)

This library uses parts of the Symfony Serializer to parse the XML files and convert them into PHP objects.

To Do
-----

[](#to-do)

This library is still work in progress. Here's what's coming in the next releases:

- \[.\] Optimize translations
- \[.\] Add more shorthand functions (like `$product->getDescriptionText()`)
- \[.\] Add a writer to create ONIX files from PHP objects

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~0 days

Total

2

Last Release

1114d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d67c041316385020aafb7eef9f11971d6fad80a11a44f4078273bda6890722d?d=identicon)[dominservice](/maintainers/dominservice)

---

Top Contributors

[![chrisribal](https://avatars.githubusercontent.com/u/3721852?v=4)](https://github.com/chrisribal "chrisribal (14 commits)")[![conatus](https://avatars.githubusercontent.com/u/317734?v=4)](https://github.com/conatus "conatus (10 commits)")[![WardVandevoort](https://avatars.githubusercontent.com/u/55634197?v=4)](https://github.com/WardVandevoort "WardVandevoort (4 commits)")[![alexschwarz89](https://avatars.githubusercontent.com/u/7203493?v=4)](https://github.com/alexschwarz89 "alexschwarz89 (2 commits)")[![cleshams](https://avatars.githubusercontent.com/u/34002404?v=4)](https://github.com/cleshams "cleshams (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/dominservice-onix-parser/health.svg)

```
[![Health](https://phpackages.com/badges/dominservice-onix-parser/health.svg)](https://phpackages.com/packages/dominservice-onix-parser)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k52.2M378](/packages/api-platform-core)[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[api-platform/symfony

Symfony API Platform integration

385.0M152](/packages/api-platform-symfony)[api-platform/serializer

API Platform core Serializer

295.3M101](/packages/api-platform-serializer)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M777](/packages/sylius-sylius)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1617.3k16](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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