2017 © Pedro Peláez
 

library json-ld

JSON-LD Processor for PHP

image

powerkernel/json-ld

JSON-LD Processor for PHP

  • Thursday, April 19, 2018
  • by powerkernel
  • Repository
  • 1 Watchers
  • 0 Stars
  • 54 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 41 Forks
  • 0 Open issues
  • 13 Versions
  • 260 % Grown

The README.md

JsonLD Build Status

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 use JsonLD is to integrate it as a dependency in your project's composer.json file:, (*4)

{
    "require": {
        "ml/json-ld": "1.*"
    }
}

Installing is then a matter of running composer, (*5)

php composer.phar install

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

require('vendor/autoload.php');

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

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

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)., (*9)

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

// 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., (*11)

The Versions

19/04 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

19/04 2018

1.0.9

1.0.9.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

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

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