Link Search Menu Expand Document

Flysystem RDF Converter Plugin

PDS Interop Project stage: Development License Latest Version standard-readme compliant Maintained

Flysystem plugin to transform RDF data between various serialization formats.

When using RDF, you will notice there are several different popular serialization formats. Instead of having to store data in multiple formats, it is easier to store the data in one format and convert it to others as needed.

This project contains a plugin to be used with Flysystem to do just that.

For the conversion EasyRDF is used. Any formats supported by EasyRDF are available from this plugin.

Currently supported formats are:

  • N-triples
  • Notation 3 / N3
  • Turtle

Table of Contents


This project is part of the PHP stack of projects by PDS Interop. It is used by both the Solid-Nextcloud app and the standalone PHP Solid server.

As the functionality seemed useful for other projects, it was implemented as a separate package.


The advised install method is through composer:

composer require pdsinterop/flysystem-rdf

PHP version 7.1 and higher is supported. The mbstring extension needs to be enabled in order for this package to work.


This package offers features to read files from a Filesystem that have been stored in one RDF format as another format.

These features are provided by a plugin and an adapter.

The plugin is best suited for light-weight scenarios where all you want to do is convert a file to another format.

The adapter is best suited for full-featured usage of Flysystem, as it also handles calls to has and getMimeType correctly (which the plugin does not)


To use the adapter, instantiate it, add it to a Flysystem filesystem and add the helper plugin.


// Create Formats objects
$formats = new \Pdsinterop\Rdf\Formats();

// Use an adapter of your choice
$adapter = new League\Flysystem\Adapter\Local('/path/to/files/');

// Create the RDF Adapter
$rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf(
    new \EasyRdf_Graph(),

// Create Flysystem as usual, adding the RDF Adapter
$filesystem = new League\Flysystem\Filesystem($rdfAdapter);

// Add the `AsMime` plugin to convert contents based on a provided MIME type, 
$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));

// Read the contents of a file in the format it was stored in
$content = $filesystem->read('/foaf.rdf');

// Read the contents of a file in another format from what was stored in
$convertedContents = $filesystem

// Get the MIME type of the format the requested mime-type would return
// This is especially useful for RDF formats that can be requested with several
// different MIME types.
$convertedMimeType = $filesystem

// This also works for `has`
$hasConvertedContents = $filesystem


To use the plugin, instantiate it and add it to a Flysystem filesystem.

The function readRdf can then be called to get RDF files in a specific format:


// Create Flysystem as usual, adding an adapter of your choice
$adapter = new League\Flysystem\Adapter\Local('/path/to/files/');
$filesystem = new League\Flysystem\Filesystem($adapter);

// create and add the RdF Plugin
$plugin = new \Pdsinterop\Rdf\Flysystem\Plugin\ReadRdf(new \EasyRdf_Graph());

// Read the contents of a RDF file in another format from what was stored in
$content = $filesystem->readRdf('/foaf.rdf', \Pdsinterop\Rdf\Enum\Format::TURTLE);


Questions or feedback can be given by opening an issue on GitHub.

All PDS Interop projects are open source and community-friendly. Any contribution is welcome! For more details read the contribution guidelines.

All PDS Interop projects adhere to the Code Manifesto as its code-of-conduct. Contributors are expected to abide by its terms.

There is a list of all contributors on GitHub.

For a list of changes see the CHANGELOG or the GitHub releases page.


All code created by PDS Interop is licensed under the MIT License.

Copyright © 2020 PDS Interop. Distributed under a MIT license.