(Translated by https://www.hiragana.jp/)
purtle - Gitiles

Fast, lightweight RDF generator

Clone this repo:
  1. 09f5982 build: Updating mediawiki/mediawiki-codesniffer to 45.0.0 by libraryupgrader · 3 days ago master
  2. 2f8b076 Use explicit nullable type on parameter arguments by Reedy · 9 days ago
  3. 5178091 build: Updating mediawiki/mediawiki-codesniffer to 44.0.0 by libraryupgrader · 3 months ago
  4. 0fba9cd build: Updating composer dependencies by libraryupgrader · 6 months ago
  5. bb1afdd Minor cleanup by Reedy · 6 months ago

Purtle

Purtle is a fast, lightweight RDF generator. It provides a "fluent" interface for generating RDF output in Turtle, JSON-LD, XML/RDF or N-Triples. The fluent interface allows the resulting PHP code to be structured just like Turtle notation for RDF, hence the name: "Purtle" is a contraction of "PHP Turtle".

The concrete classes implementing the common RdfWriter interface are:

  • TurtleRdfWriter outputs Turtle
  • JsonLdRdfWriter outputs JSON-LD
  • XmlRdfWriter outputs XML/RDF
  • NTriplesRdfWriter outputs N-Triples

The PHP code would look something like this:

$writer = new TurtleRdfWriter();

$writer->prefix( 'acme', 'http://acme.test/terms/' );

$writer->about( 'http://quux.test/Something' )
  ->a( 'acme', 'Thing' )
  ->say( 'acme', 'name' )->text( 'Thingy' )->text( 'Dingsda', 'de' )
  ->say( 'acme', 'owner' )->is( 'http://quux.test/' );