wikimedia / purtle
Fast streaming RDF serializer
v2.0.0
2024-11-10 02:02 UTC
Requires
- php: >=7.4
- ext-json: *
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 45.0.0
- mediawiki/mediawiki-phan-config: 0.14.0
- mediawiki/minus-x: 1.1.3
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpmd/phpmd: ~2.3
- phpunit/phpunit: 9.6.16
README
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 TurtleJsonLdRdfWriter
outputs JSON-LDXmlRdfWriter
outputs XML/RDFNTriplesRdfWriter
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/' );