Debian Codegraph @

vendor/wikimedia/purtle/README.md

raw
1 # Purtle
2
3 **Purtle** is a fast, lightweight RDF generator. It provides a "fluent" interface for
4 generating RDF output in Turtle, JSON-LD, XML/RDF or N-Triples. The fluent interface allows the
5 resulting PHP code to be structured just like Turtle notation for RDF, hence the name: "Purtle"
6 is a contraction of "PHP Turtle".
7
8 The concrete classes implementing the common `RdfWriter` interface are:
9 * `TurtleRdfWriter` outputs Turtle
10 * `JsonLdRdfWriter` outputs JSON-LD
11 * `XmlRdfWriter` outputs XML/RDF
12 * `NTriplesRdfWriter` outputs N-Triples
13
14 The PHP code would look something like this:
15
16 ```php
17 $writer = new TurtleRdfWriter();
18
19 $writer->prefix( 'acme', 'http://acme.test/terms/' );
20
21 $writer->about( 'http://quux.test/Something' )
22 ->a( 'acme', 'Thing' )
23 ->say( 'acme', 'name' )->text( 'Thingy' )->text( 'Dingsda', 'de' )
24 ->say( 'acme', 'owner' )->is( 'http://quux.test/' );
25 ```