2017 © Pedro Peláez
 

library json-ld

JSON-LD Processor for PHP

image

ml/json-ld

JSON-LD Processor for PHP

  • Sunday, January 28, 2018
  • by markus
  • Repository
  • 20 Watchers
  • 212 Stars
  • 145,994 Installations
  • PHP
  • 27 Dependents
  • 2 Suggesters
  • 42 Forks
  • 36 Open issues
  • 13 Versions
  • 6 % Grown

The README.md

JsonLD Continuous integration

JsonLD is a fully conforming JSON-LD processor written in PHP. It is extensively tested and passes the official JSON-LD test suite., (*1)

There's an online playground where you can evaluate the processor's basic functionality., (*2)

Additionally to the features defined by the JSON-LD API specification, JsonLD supports framing (including value matching, deep-filtering, aggressive re-embedding, and named graphs) and an experimental object-oriented interface for JSON-LD documents., (*3)

Installation

The easiest way to install JsonLD is by requiring it with Composer., (*4)

composer require ml/json-ld

... and including Composer's autoloader to your project, (*5)

require('vendor/autoload.php');

Of course, you can also download JsonLD as ZIP archive from Github., (*6)

JsonLD requires PHP 5.3 or later., (*7)

Usage

The library supports the official JSON-LD API as well as a object-oriented interface for JSON-LD documents (not fully implemented yet, see issue #15 for details)., (*8)

All classes are extensively documented. Please have a look at the source code., (*9)

// Official JSON-LD API
$expanded = JsonLD::expand('document.jsonld');
$compacted = JsonLD::compact('document.jsonld', 'context.jsonld');
$framed = JsonLD::frame('document.jsonld', 'frame.jsonld');
$flattened = JsonLD::flatten('document.jsonld');
$quads = JsonLD::toRdf('document.jsonld');

// Output the expanded document (pretty print)
print JsonLD::toString($expanded, true);

// Serialize the quads as N-Quads
$nquads = new NQuads();
$serialized = $nquads->serialize($quads);
print $serialized;

// And parse them again to a JSON-LD document
$quads = $nquads->parse($serialized);
$document = JsonLD::fromRdf($quads);

print JsonLD::toString($document, true);

// Node-centric API
$doc = JsonLD::getDocument('document.jsonld');

// get the default graph
$graph = $doc->getGraph();

// get all nodes in the graph
$nodes = $graph->getNodes();

// retrieve a node by ID
$node = $graph->getNode('http://example.com/node1');

// get a property
$node->getProperty('http://example.com/vocab/name');

// add a new blank node to the graph
$newNode = $graph->createNode();

// link the new blank node to the existing node
$node->addPropertyValue('http://example.com/vocab/link', $newNode);

// even reverse properties are supported; this returns $newNode
$node->getReverseProperty('http://example.com/vocab/link');

// serialize the graph and convert it to a string
$serialized = JsonLD::toString($graph->toJsonLd());

Commercial Support

Commercial support is available on request., (*10)

The Versions

28/01 2018

dev-master

9999999-dev http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

28/01 2018

1.0.8

1.0.8.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

28/01 2018

dev-fix-tests

dev-fix-tests http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

10/10 2016

1.0.7

1.0.7.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

25/08 2016

1.0.6

1.0.6.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

17/01 2016

1.0.5

1.0.5.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

22/12 2015

1.0.4

1.0.4.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

07/11 2015

dev-expansion-debug

dev-expansion-debug http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

15/09 2014

1.0.3

1.0.3.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

07/07 2014

1.0.2

1.0.2.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

20/03 2014

1.0.1

1.0.1.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

19/03 2014

1.0.0

1.0.0.0 http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

json-ld jsonld

05/03 2013

dev-property-generators

dev-property-generators http://www.markus-lanthaler.com

JSON-LD Processor for PHP

  Sources   Download

MIT

The Requires

 

json-ld jsonld