Php sesame interface

Installs: 49

Dependents: 0

Stars: 2

Watchers: 1

Forks: 1

Open Issues: 1

v2.0.0 2014-05-27 09:02 UTC



Fork of the alex latchford sesame interface Inspired by the work of Julian Klotz, and Andreas Thalhammer


  • PHP 5+ <>_ - (There shouldn't be any subversion dependencies, but I haven't checked thoroughly)
  • HTTP_Request2 <>_
  • semsol/ARC2 <> library, available here on github, is strongly recommended to parse results or generate rdf.


I am assuming at this point you have installed and configured Sesame, have a repository set up and the REST API functioning correctly. If not then please consult the Sesame documentation <>_.

Using the Library

To get the library up and running all you need is::

require_once "path/to/phpSesame/phpSesame.php";

$sesame = array('url' => 'http://localhost:8080/openrdf-sesame', 'repository' => 'exampleRepo', 'charset' => 'UTF-8');
$store = new phpSesame($sesame['url'], $sesame['repository'],  $sesame['charset']);

You can change the repository you are working on at any time by calling::


Charset param is used for both content type and accept headers params. You can set them specifically by calling::


Querying a Store

The simplest way to query a store is::

$sparql = "PREFIX foaf:<>
SELECT ?s ?o WHERE { ?s foaf:name ?o } LIMIT 100";
$resultFormat = phpSesame::SPARQL_XML; // The expected return type, will return a phpSesame_SparqlRes object (Optional)
$lang = "sparql"; // Can also choose SeRQL (Optional)
$infer = true; // Can also choose to explicitly disallow inference. (Optional)

$result = $store->query($sparql, $resultFormat, $lang, $infer);

Using ARC2 for results::

    $parser = ARC2::getSPARQLXMLResultParser();
    $parser->parse('', $result);
    foreach($parser->getRows() as $row) {
            echo "Subject: " . $row['s'] . ", Object: " . $row['o'] . ".";

Documentation will be updated with new features examples soon.