2017 © Pedro Peláez
 

library nemrod

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

image

conjecto/nemrod

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  • Tuesday, March 14, 2017
  • by bdecarne
  • Repository
  • 10 Watchers
  • 22 Stars
  • 651 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 10 Versions
  • 2 % Grown

The README.md

Nemrod

What is Nemrod?

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project, in the same way Symfony users are using Doctrine. The framework provides five main components:, (*1)

  • a resource manager (similar to Doctrine's resource manager)
  • a SPARQL query builder allowing to interact directly with your sparql endpoint(s)
  • a form extension allowing to build forms to create or update data
  • a json-ld serializer allowing to produce framed json-ld representation of RDF
  • Optionally, a set of services can be set up that populates and update an Elasticsearch server wrt triple store content.

Nemrod mainly relies on, (*2)

Demo project

A quick way to test Nemrod Abilities before installing it into your project is to try our demo project, (*3)

Requirements

Installation

Nemrod can be installed using composer :, (*4)

composer require conjecto/nemrod easyrdf/easyrdf:@dev conjecto/json-ld:@dev

you can also add dependency directly in your composer.json file:, (*5)

"conjecto/nemrod": "master"
"easyrdf/easyrdf": "@dev"
"conjecto/json-ld": "@dev"

Then you need to add one (or two) bundle(s) to the AppKernel.php:, (*6)

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Conjecto\Nemrod\Bundle\NemrodBundle\NemrodBundle(),
            new Conjecto\Nemrod\Bundle\ElasticaBundle\ElasticaBundle(),
            ...
        );
    }
}

The first bundle is the main framework bundle, the second should be enabled only if you wish to use an ElasticSearch server., (*7)

A little bit of configuration is necessary to let Nemrod know one thing or two about your environment:, (*8)

nemrod:
  endpoints:
    my_endpoint: "http://www.foo.org/sparql"
    another_endpoint: "http://www.bar.net/sparql"
  default_endpoint: my_endpoint
  namespaces:
    rdfs: "http://www.w3.org/2000/01/rdf-schema#"
    foaf: "http://xmlns.com/foaf/0.1/"
    #add the namespaces you need
    mycompany: "http://www.example.org/mycompany"

At this point, Nemrod knows enough to access to your data. Use the 'rm' service's findAll() (which is an alias for 'nemrod.resource_manager.my_endpoint'):, (*9)

<?php

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class ProductsController extends Controller
{
    /**
     * @Route("/all/", name="product.index")
     * @Template("ProductsBundle:index.html.twig")
     */
    public function indexAction()
    {
        $products = $this->container->get('rm')->getRepository('mycompany:Product')->findAll();
        ...
        return array("products" => $products);
    }
}

Alternatively, you can refine the set of data you want to get using the findBy() method:, (*10)

    /**
     * @Route("/category/{category}", name="product.category")
     * @Template("ProductsBundle:index.html.twig")
     */
    public function categoryAction($category)
    {
        $products = $this->container->get('rm')
            ->getRepository('mycompany:Product')
            ->findBy(array('mycompany:category' => $category));
        ...
        return array("products" => $products);
    }

You can then display your data using twig:, (*11)

<ul>
    {% for product in products %}
        <li class="list-group-item">{{ product['rdfs:label'].value }}</li>
    {% endfor %}
</ul>

Another possibility is to ask for a specific resource using its uri:, (*12)

    /**
     * @Route("/view/{uri}", name="product.view")
     * @Template("ProductsBundle:view.html.twig")
     */
    public function viewAction($uri)
    {
        $product = $this->container->get('rm')
            ->getRepository('mycompany:Product')
            ->find($uri);
        ...
        return array("product" => $product);
    }

You can also use the paramConverter to get the resource directly. In this example, the product variable is automatically instanciated., (*13)

    /**
     * @Route("/view/{uri}", name="product.view")
     * @ParamConverter("product", class="mycompany:Product")
     * @Template("ProductsBundle:view.html.twig")
     */
    public function viewAction($product)
    {
        return array("product" => $product);
    }

If you need to encapsulate specific logic over your data, you can overload the default resource abstraction class. Overloading class must be defined in a RdfResource directory of your bundle directory:, (*14)

+-- ProductBundle
|   +-- Controller
|   +-- DependencyInjection
|   +-- Resources
|   +-- RdfResource
|       +-- Product

and must extend Conjecto\Nemrod\Resource (which is the default abstraction class):, (*15)

<?php

namespace MyCompany\ProductBundle\RdfResource;

use Conjecto\Nemrod\Resource as BaseResource;
use Conjecto\Nemrod\ResourceManager\Annotation\Resource;

/**
 * Class Product
 * @Resource(types={"mycompany:Product"}, uriPattern = "mycompany:product:")
 */
class Product extends BaseResource
{

}

the @Resource annotation allows to map your class and RDF types, so you can get an instance of this class when asking for object with the given types:, (*16)

$product = $this->container->get('rm')->getRepository('mycompany:Product')->find($uri);

will fill $products with an array of MyCompany\ProductBundle\RdfResource\Product objects., (*17)

An URI pattern can also be provided with uriPattern. It will be used to set an URI for a new resource. For now, the specified pattern is just used as a prefix, (*18)

Documentation

Contributing

  • Feel free to install and test the framework. We'd love to have some feedback about it.
  • A lot of tests has to be written. We are currently putting effort on that point. Any help would be appreciated.

Licensing

The Nemrod framework is licensed under the BSD-3-Clause license., (*19)

The Versions

14/03 2017

dev-dev-nawer

dev-dev-nawer http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

05/08 2016

dev-develop

dev-develop http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

27/06 2016

dev-dev-blaise

dev-dev-blaise http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

24/06 2016

dev-dev-query-builder

dev-dev-query-builder http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

18/05 2016

dev-master

9999999-dev http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

12/04 2016

dev-feature-independant-library

dev-feature-independant-library http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

06/04 2016

dev-feature-batch-serializer

dev-feature-batch-serializer http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

22/03 2016

dev-feature-fix-query-hydrator

dev-feature-fix-query-hydrator http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

22/04 2015

v0.1.1

0.1.1.0 http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld

26/03 2015

0.1.0

0.1.0.0 http://www.conjecto.com

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rdfa rdf semantic web turtle sparql linked data jsonld