Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (53 sloc) 1.98 KB
* Example of using Zend_Http_Client and Zend_Loader_Autoloader with EasyRdf
* This example creates a simple graph in memory, saves it to a local
* graphstore and then fetches the data back using a SPARQL SELECT query.
* Zend's curl HTTP client adaptor is used to perform the HTTP requests.
* @package EasyRdf
* @copyright Copyright (c) 2009-2011 Nicholas J Humfrey
* @license
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
// require the Zend Autoloader
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// use the CURL based HTTP client adaptor
$client = new Zend_Http_Client(
null, array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'keepalive' => true,
'useragent' => "EasyRdf/zendtest"
// Load the parsers and serialisers that we are going to use
# FIXME: better way to do this?
<title>Zend Framework Example</title>
<h1>Zend Framework Example</h1>
# Load some sample data into a graph
$graph = new EasyRdf_Graph('');
$joe = $graph->resource('', 'foaf:Person');
$joe->add('foaf:name', 'Joe Bloggs');
$joe->addResource('foaf:homepage', '');
# Store it in a local graphstore
$store = new EasyRdf_GraphStore('http://localhost:8080/data/');
# Now make a query to the graphstore
$sparql = new EasyRdf_Sparql_Client('http://localhost:8080/sparql/');
$result = $sparql->query('SELECT * WHERE {<> ?p ?o}');
echo $result->dump();
Jump to Line
Something went wrong with that request. Please try again.