PHPackages                             kjantzer/ponipar - 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. kjantzer/ponipar

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

kjantzer/ponipar
================

Stream-based PHP ONIX parser library.

0.2.0(7y ago)811.1k5[1 issues](https://github.com/kjantzer/PONIpar/issues)[1 PRs](https://github.com/kjantzer/PONIpar/pulls)MITPHPPHP &gt;=5.3.0

Since Dec 18Pushed 5y ago3 watchersCompare

[ Source](https://github.com/kjantzer/PONIpar)[ Packagist](https://packagist.org/packages/kjantzer/ponipar)[ Docs](https://github.com/kjantzer/PONIpar)[ RSS](/packages/kjantzer-ponipar/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

PONIpar – PHP ONIX Parser
=========================

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

[![status](https://camo.githubusercontent.com/97853aafc04381cf0aea421ee4fc6821b2a5bef697e1258a92e58a3121a0a236/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d5061727469616c6c79253230446576656c6f7065642d626c75652e737667)](https://github.com/kjantzer/PONIpar/tree/master)[![version](https://camo.githubusercontent.com/36bfef44366976315d1d0b5f4189213edb7139e900a4c7e66715788e19c16545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6a616e747a65722f504f4e497061722e737667)](https://packagist.org/packages/kjantzer/ponipar)

Main Features
-------------

[](#main-features)

- stream based: can read ONIX files of arbitrary length, because it does not keep the whole file in memory
- convenient variety of inputs: pass your data from a file, URL, stream, stdin or string
- callback based: you define a callable (function, method, closure) for every aspect of the ONIX file you are interested in, which will then be called by PONIpar while parsing (currently, only the Product callback is implemented)
- universal: uses reference names internally, but reads (and converts) short tags as well (not complete, currently only reference names fully work)
- high-level: PONIpar handles the XML parsing events and provides your callbacks with already parsed, high level object instances like “Product” and “Contributor” (not complete yet)
- modern: namespaced PHP 5.3 code
- flexible: since PONIpar doesn’t force you into a certain way of handling the data, you are free to code the way that best matches your requirements
- international: converts every input charset to UTF-8 and thus provides you with UTF-8 strings only (not implemented yet)

Current Status
--------------

[](#current-status)

PONIpar is partially developed (enough for basic use). It recognizes `` elements and calls a user-defined callback for each one found, passing a high-level `Product` object that currently allows accessing the product data via standard DOM calls and one or two high-level convenience classes and methods. The first high-level class (for ProductIdentifiers) is already there.

Other high-level classes have been built but are a work in progress and will likely need improving. You can see which ones are available by looking in [ProductSubitem](https://github.com/kjantzer/PONIpar/tree/master/src/ProductSubitem) directory.

You *can* use it in a production environment but you'll want to run tests to make sure the data you need is being parsed correctly. Some of the `` properties will have to be retrieved manually.

TODO
----

[](#todo)

- Add more `ProductSubitems`

Example Usage
-------------

[](#example-usage)

Set which classes we are going to reference at the top of your file. We do this so we can use shorter class names.

```
use PONIpar\Parser;
use PONIpar\ProductSubitem\ProductIdentifier;
use PONIpar\ProductSubitem\Title;
use PONIpar\ProductSubitem\Contributor;
use PONIpar\ProductSubitem\Extent;
use PONIpar\ProductSubitem\SupplyDetail;
```

Create a function to handle getting the data from each ``

```
$parse_product = function($product){

	$isbn_13 = $product->getIdentifier(ProductIdentifier::TYPE_ISBN13);

	// there can be multiple titles
	$titles = $product->getTitles();
	$main_title = '';

	// find the  main title
	foreach ($titles as $item) {
		if( $item->getType() == Title::TYPE_DISTINCTIVE_TITLE )
			$main_title = $item->getValue();
	}

	// get list of contributor names
	$contributors = $product->getContributors();
	$contributor_names = array_map(function($c){
		return $c->getName();
	}, $contributors);

	$bisac = $product->getMainSubjectBISAC();

	$description = $product->getMainDescription();

	$is_active = $product->isActive();

	// get supply info
	$supply_details = $product->getSupplyDetails();

	$supply_detail = $supply_details[0];

	$supply_detail->getOnSaleDate();
	$supply_detail->getPrices();
}
```

Begin parsing an ONIX file. The `parse_product` function above will be called for every ``.

```
$parser = new Parser();
$parser->useFile($file);
$parser->setProductHandler($parse_product);
$parser->parse();
```

Requirements
------------

[](#requirements)

PONIpar requires at least PHP 5.3 with the “XML Parser” extension.

Author
------

[](#author)

PONIpar is authored by [UEBERBIT GmbH](http://www.ueberbit.de) with additional development by [Blackstone Publishing, Inc.](http://www.blackstonepublishing.com)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.1% 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 ~1035 days

Total

2

Last Release

2761d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/34ff338968185cccad4dadffea5690d87cffd8e5fe76487dd451123876a66dae?d=identicon)[kjantzer](/maintainers/kjantzer)

---

Top Contributors

[![kjantzer](https://avatars.githubusercontent.com/u/467487?v=4)](https://github.com/kjantzer "kjantzer (27 commits)")[![Rkallenkoot](https://avatars.githubusercontent.com/u/3198607?v=4)](https://github.com/Rkallenkoot "Rkallenkoot (5 commits)")[![jacobsenj](https://avatars.githubusercontent.com/u/399303?v=4)](https://github.com/jacobsenj "jacobsenj (3 commits)")

---

Tags

xmlparseronixediteur

### Embed Badge

![Health badge](/badges/kjantzer-ponipar/health.svg)

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

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[imangazaliev/didom

Simple and fast HTML parser

2.2k2.3M64](/packages/imangazaliev-didom)[orchestra/parser

XML Document Parser for Laravel and PHP

4581.7M5](/packages/orchestra-parser)[laravie/parser

XML Document Parser for PHP

2342.1M8](/packages/laravie-parser)[goetas-webservices/xsd-reader

Read any XML Schema (XSD) programmatically with PHP

624.7M15](/packages/goetas-webservices-xsd-reader)[vipnytt/sitemapparser

XML Sitemap parser class compliant with the Sitemaps.org protocol.

772.2M10](/packages/vipnytt-sitemapparser)

PHPackages © 2026

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