I need to request an rdf file with some SPARQL Query. And I have to do it in PHP. I test my code with WAMP.
Is it possible to request rdf file locally with sparql query in php ? If yes, is it possible to do it with "Easyrdf". I found EasyRDF and i try it but I don't really know how it's work, I didn't find anyway to put rdf file locally in the code. So, if it's possible can you please check my code to see what's wrong with it ?
require "C:/Users/adela/vendor/autoload.php";
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "C:/Users/adela/easyrdf-0.9.0/lib/EasyRdf.php";
require_once "C:/Users/adela/easyrdf-0.9.0/examples/html_tag_helpers.php";
EasyRdf_Namespace::set('ns', 'http://www.it-sudparis.eu/family#');
EasyRdf_Namespace::set('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
EasyRdf_Namespace::set('rdfs', 'http://www.w3.org/2000/01/rdf-schema#');
EasyRdf_Namespace::set('owl', 'http://www.w3.org/2002/07/owl#');
EasyRdf_Namespace::set('xsd', 'http://www.w3.org/2001/XMLSchema#');
EasyRdf_Namespace::set('tg', 'http://www.turnguard.com/functions#');
EasyRdf_Namespace::set('cd', 'https://www.project_aikm_20170547/cd#');
$sparql = new EasyRdf_Sparql_Client('http://localhost/Knowledge_Project/lib/EasyRdf/Sparql');
$result = $sparql->query(
'SELECT * WHERE {'.
' ?p ?s ?o .'.
'}'
);
print_r($result);
foreach ($result as $row) {
echo print_r($row);
}
There is no error and this is the result of the print_r($result):
EasyRdf_Graph Object ( [uri:EasyRdf_Graph:private] => http://localhost/Knowledge_Project/lib/EasyRdf/Sparql [parsedUri:EasyRdf_Graph:private] => EasyRdf_ParsedUri Object ( [scheme:EasyRdf_ParsedUri:private] => http [fragment:EasyRdf_ParsedUri:private] => [authority:EasyRdf_ParsedUri:private] => localhost [path:EasyRdf_ParsedUri:private] => /Knowledge_Project/lib/EasyRdf/Sparql [query:EasyRdf_ParsedUri:private] => ) [resources:EasyRdf_Graph:private] => Array ( ) [index:EasyRdf_Graph:private] => Array ( ) [revIndex:EasyRdf_Graph:private] => Array ( ) [bNodeCount:EasyRdf_Graph:private] => 0 [loaded:EasyRdf_Graph:private] => Array ( ) [maxRedirects:EasyRdf_Graph:private] => 10 )
I already check that the program doesn't go in the foreachloop.
PS:
Window version: 10 ; PHP version: 7.3.12 ; WAMP version: 3.2.0
Update: If i pass in 7.4.1 version of PHP the script give a lot of error:
