EasyRdf is a PHP library designed to make it easy to consume and produce RDF.
PHP Makefile
Latest commit 1371c8a Nov 1, 2015 @njh Merge pull request #256 from ragol/serialiser-typehint
Use type hints in Seraliser classes
Failed to load latest commit information.
docs fixed docblocks and documentation-files Nov 7, 2014
examples Fixed Google Map on UK Postcode example Dec 28, 2014
lib Merge pull request #256 from ragol/serialiser-typehint Nov 1, 2015
scripts Wrote script to update the copyright year Mar 4, 2013
.gitattributes Added .gitattributes file, removing several directories from the Gith… Jan 17, 2013
.travis.yml Removed HHVM from Travis for now (see #225) Dec 27, 2014
Makefile "--dev" is the default for a long time now Mar 20, 2015
README.md Moved the Build Status to under the title Dec 28, 2014
composer.json semver compatible name Nov 7, 2014



Build Status

EasyRdf is a PHP library designed to make it easy to consume and produce RDF. It was designed for use in mixed teams of experienced and inexperienced RDF developers. It is written in Object Oriented PHP and has been tested extensively using PHPUnit.

After parsing EasyRdf builds up a graph of PHP objects that can then be walked around to get the data to be placed on the page. Dump methods are available to inspect what data is available during development.

Data is typically loaded into a EasyRdf\Graph object from source RDF documents, loaded from the web via HTTP. The EasyRdf\GraphStore class simplifies loading and saving data to a SPARQL 1.1 Graph Store.

SPARQL queries can be made over HTTP to a Triplestore using the EasyRdf\Sparql\Client class. SELECT and ASK queries will return an EasyRdf\Sparql\Result object and CONSTRUCT and DESCRIBE queries will return an EasyRdf\Graph object.


$foaf = new \EasyRdf\Graph("http://njh.me/foaf.rdf");
$me = $foaf->primaryTopic();
echo "My name is: ".$me->get('foaf:name')."\n";


The latest stable version of EasyRdf can be downloaded from the EasyRdf website.



  • PHP 5.3 or higher


  • API documentation written in phpdoc
  • Extensive unit tests written using phpunit
  • Built-in parsers and serialisers: RDF/JSON, N-Triples, RDF/XML, Turtle
  • Optional parsing support for: ARC2, Redland Bindings, rapper
  • Optional support for Zend\Http\Client
  • No required external dependancies upon other libraries (PEAR, Zend, etc...)
  • Complies with Zend Framework coding style.
  • Type mapper - resources of type foaf:Person can be mapped into PHP object of class Foaf_Person
  • Support for visualisation of graphs using GraphViz
  • Comes with a number of examples

More Examples


The EasyRdf library and tests are licensed under the BSD-3-Clause license. The examples are in the public domain, for more information see UNLICENSE.