PHPackages                             sweetrdf/rdf-interface - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sweetrdf/rdf-interface

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sweetrdf/rdf-interface
======================

A common RDF interface for PHP RDF libraries.

3.2.0(1y ago)71.1M—5.8%2[1 issues](https://github.com/sweetrdf/rdfInterface/issues)10MITPHPPHP &gt;=8.0

Since Jan 16Pushed 1y ago3 watchersCompare

[ Source](https://github.com/sweetrdf/rdfInterface)[ Packagist](https://packagist.org/packages/sweetrdf/rdf-interface)[ Docs](https://github.com/sweetrdf/rdfInterface)[ RSS](/packages/sweetrdf-rdf-interface/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (41)Used By (10)

RDF interfaces for PHP
======================

[](#rdf-interfaces-for-php)

Why do we need common interfaces?
---------------------------------

[](#why-do-we-need-common-interfaces)

The PHP RDF ecosystem suffers from big monolythic libraries trying to provide a full RDF stack from parsers to triplestores, serializers and sometimes even SPARQL engines in one library.

It makes them quite difficult to maintain and extend. It also makes it impossible to couple parts of different libraries with each other, e.g. combine a faster parser from one library with a nicer triplestore from another.

The solution for these troubles is to agree on

- A set of separate RDF stack layers: parser, serializer, dataset, SPARQL client, etc.
- Common interfaces each layer should use to communicate with the other (think of it as a PSR-7 for RDF).

Implementations
---------------

[](#implementations)

- The reference implementation of `Term` and the `Dataset` classes are provided by the [quickRdf](https://github.com/sweetrdf/quickRdf) library and the [simpleRdf](https://github.com/sweetrdf/simpleRdf) library.
- Turtle, NTriples, NQuads and NTriplesStar parsers and serialisers are provided by the [quickRdfIo](https://github.com/sweetrdf/quickRdfIo) library.
- A collection of `QuadTemplate` and `LiteralTemplate` classes providing a convenient way for quads/triples filtering can be found in the [termTemplates](https://github.com/sweetrdf/termTemplates) library.
- The [sparqlClient](https://github.com/sweetrdf/sparqlClient) library provides a SPARQL client (still in early development).
- Generic helpers which can be reuesed when developing your own implementations or plugging foreign code can be found in the [rdfHelpers](https://github.com/sweetrdf/rdfHelpers) library.

Compliance tests
----------------

[](#compliance-tests)

The [rdfInterfaceTests](https://github.com/sweetrdf/rdfInterfaceTests) provides a set of tests for validating if your library is compliant with the rdfInterface.

For EasyRdf users
-----------------

[](#for-easyrdf-users)

If you are using EasyRdf, you are likely to find the rdfInterface API quite strange and difficult to understand.
[This document](EasyRdfReadme.md) should help.

There's also an [rdfInterface2easyRdf](https://github.com/sweetrdf/rdfInterface2easyRdf) library which provides conversion routines between rdfInterface and EasyRdf (in both directions).

Design decisions
----------------

[](#design-decisions)

### Inspirations

[](#inspirations)

The rdfInterface is strongly influenced by [RDF/JS](http://rdf.js.org/) and [RDFLib](https://rdflib.readthedocs.io/en/stable/).

### Strong typing

[](#strong-typing)

The rdfInterface is strongly typed.

Strong typing provides many benefits. It assures the syntax is unambiguous and extensible, allows to leverage static code analysis and makes errors easier to understand.

The downside of strong typing is much more verbose syntax but we decided benefits outweight it easily.

### Immutability

[](#immutability)

RdfInterface terms are immutable. It's impossible to change their properties. You can only get a new object instance with a given property set to a new value.

Immutability provides three benefits:

1. It makes it clear for the programmer that there is no back-propagation of changes.
2. It's easy to implement it without flaws (in contrary to deep cloning).
3. It allows to implement useful performance optimizations (e.g. a global term cache).

And modern PHP should be already familiar with it as e.g. PSR-7 request/response objects follow the same approach.

### Use streams for data import and export

[](#use-streams-for-data-import-and-export)

RdfInterface uses streams as RDF parsing input and serialization output.

Streams are far more flexible than strings. They allow asynchronous operation, have lower memory footprint, fit the PSR-7 interface nicely and much more.

Last but not least a string can be easilly packed into a in-memory stream.

### Reuse native PHP interfaces

[](#reuse-native-php-interfaces)

RdfInterface, especially the `Dataset` interface extends native PHP interfaces, e.g.:

- [iterable](https://www.php.net/manual/en/language.types.iterable.php) over edges/nodes of a dataset.
- [ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php) for adding/removing/accessing edges of a dataset.
- [Countable](https://www.php.net/manual/en/class.countable.php) for e.g. counting quads in a dataset.

Using native interfaces makes the library easier to learn and it feels better integrated with the PHP ecosystem.

### Extensibility

[](#extensibility)

RdfInterface is meant to be extensible.

RDF is changing with new ideas being introduced (like RDF-star) and the API should be able to accomodate such developments.

For that reason the `Quad` specification is rather relaxed and allows any term as a subject and object.

It doesn't mean all implementations must support any possible term. Implementations may support any subset they want, just checking if they can deal with a term they recive from user is their responsibility.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance45

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~47 days

Recently: every ~111 days

Total

34

Last Release

385d ago

Major Versions

0.11.0 → 1.0.0-RC12022-10-24

1.0.1 → 2.0.0-RC12023-07-26

2.1.0 → 3.0.02025-04-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1f662e3acb95efd9208cdcd2c97437db366044aea705985251760efcbd23070?d=identicon)[zozlak](/maintainers/zozlak)

---

Top Contributors

[![zozlak](https://avatars.githubusercontent.com/u/6503177?v=4)](https://github.com/zozlak "zozlak (201 commits)")[![k00ni](https://avatars.githubusercontent.com/u/381727?v=4)](https://github.com/k00ni "k00ni (8 commits)")[![dunglas](https://avatars.githubusercontent.com/u/57224?v=4)](https://github.com/dunglas "dunglas (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sweetrdf-rdf-interface/health.svg)

```
[![Health](https://phpackages.com/badges/sweetrdf-rdf-interface/health.svg)](https://phpackages.com/packages/sweetrdf-rdf-interface)
```

###  Alternatives

[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[phpgt/dom

Modern DOM API.

12412.2M18](/packages/phpgt-dom)[anthropic-ai/sdk

Anthropic PHP SDK

129134.7k5](/packages/anthropic-ai-sdk)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[shopware/app-php-sdk

Shopware App SDK for PHP

1577.8k1](/packages/shopware-app-php-sdk)[eliashaeussler/typo3-form-consent

Extension for TYPO3 CMS that adds double opt-in functionality to EXT:form

1481.0k](/packages/eliashaeussler-typo3-form-consent)

PHPackages © 2026

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