wikimedia / purtle
快速流式RDF序列化器
v1.0.8
2021-06-17 14:47 UTC
Requires
- php: >=7.2.9
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 36.0.0
- mediawiki/minus-x: 1.1.1
- ockcyp/covers-validator: 1.3.3
- php-parallel-lint/php-console-highlighter: 0.5.0
- php-parallel-lint/php-parallel-lint: 1.3.0
- phpmd/phpmd: ~2.3
- phpunit/phpunit: ^8.5
README
Purtle是一个快速、轻量级的RDF生成器。它提供了一个“流畅”的接口,用于生成Turtle、JSON-LD、XML/RDF或N-Triples格式的RDF输出。流畅的接口允许生成的PHP代码结构类似于RDF的Turtle表示法,因此得名:“Purtle”是“PHP Turtle”的缩写。
实现通用RdfWriter
接口的具体类包括
TurtleRdfWriter
输出Turtle格式JsonLdRdfWriter
输出JSON-LD格式XmlRdfWriter
输出XML/RDF格式NTriplesRdfWriter
输出N-Triples格式
PHP代码可能看起来像这样
$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/' );