PHPackages                             pietercolpaert/hardf - 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. pietercolpaert/hardf

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

pietercolpaert/hardf
====================

A fast parser for RDF serializations such as turtle, n-triples, n-quads, trig and N3

0.6.2(1mo ago)38165.0k↓25.1%7[1 issues](https://github.com/pietercolpaert/hardf/issues)[1 PRs](https://github.com/pietercolpaert/hardf/pulls)6MITPHPPHP ^7.1|^8.0CI passing

Since Apr 3Pushed 3w ago5 watchersCompare

[ Source](https://github.com/pietercolpaert/hardf)[ Packagist](https://packagist.org/packages/pietercolpaert/hardf)[ Docs](https://github.com/pietercolpaert/hardf)[ RSS](/packages/pietercolpaert-hardf/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (8)Versions (22)Used By (6)

The Hardf RDF 1.2 Turtle, N-Triples, N-Quads, and TriG parser for PHP
=====================================================================

[](#the-hardf-rdf-12-turtle-n-triples-n-quads-and-trig-parser-for-php)

[![PHP CI](https://github.com/pietercolpaert/hardf/actions/workflows/php-ci.yml/badge.svg)](https://github.com/pietercolpaert/hardf/actions/workflows/php-ci.yml)[![W3C RDF1.2 spec compliance](https://github.com/pietercolpaert/hardf/actions/workflows/spec-compliance.yml/badge.svg)](https://github.com/pietercolpaert/hardf/actions/workflows/spec-compliance.yml)[![Latest stable release](https://camo.githubusercontent.com/dab5b66623194a9d2acb85f762092ec538fbc815849bf2eaae2bc182f1dbde25/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706965746572636f6c70616572742f6861726466)](https://packagist.org/packages/pietercolpaert/hardf)

**Hardf** is a PHP 7.1+ library that lets you handle Linked Data (RDF 1.2). It offers [**parsing**](#parsing) from and [**writing**](#writing) in [Turtle](http://www.w3.org/TR/turtle/), [TriG](http://www.w3.org/TR/trig/), [N-Triples](http://www.w3.org/TR/n-triples/), and [N-Quads](http://www.w3.org/TR/n-quads/). Both the parser and the serializer have *streaming* support.

Hardf also supports [RDF 1.2](https://www.w3.org/TR/rdf12-concepts/) features that are relevant to this representation, including triple terms, reified triples, annotation syntax, directional language literals, `VERSION` declarations, and [RDF Messages](https://w3c-cg.github.io/rsp/spec/messages). Conformances is [tested using the official test suites](#rdf-working-group-test-suites).

This library was started as a port of [N3.js](https://github.com/rdfjs/N3.js/tree/v0.10.0) to PHP.

Triple Representation
---------------------

[](#triple-representation)

On purpose, we focused on performance, and not on developer friendliness. We have thus implemented this triple representation using associative arrays rather than PHP objects. For example:

```
