PHPackages                             bordercloud/sparql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. bordercloud/sparql

ActiveLibrary

bordercloud/sparql
==================

Lib PHP very easy for SPARQL 1.1

2.2.0(8mo ago)27100.4k—3.1%6[2 PRs](https://github.com/BorderCloud/SPARQL/pulls)CC-BY-SA-4.0PHPPHP &gt;=8.1CI passing

Since Aug 16Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/BorderCloud/SPARQL)[ Packagist](https://packagist.org/packages/bordercloud/sparql)[ Docs](https://github.com/BorderCloud/SPARQL)[ GitHub Sponsors](https://github.com/BorderCloud)[ RSS](/packages/bordercloud-sparql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (12)Used By (0)

[![Build Status](https://camo.githubusercontent.com/a170814a5e4c9690d09f637c557ba1e76a12a92d01b2afd048c4a247eb4eca8c/68747470733a2f2f7472617669732d63692e6f72672f426f72646572436c6f75642f53504152514c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/BorderCloud/SPARQL)

Lib Sparql 1.1 HTTP Client
--------------------------

[](#lib-sparql-11-http-client)

Very simple SparqlClient for PHP.

Thanks to [contributors](https://github.com/BorderCloud/SPARQL/graphs/contributors).

### Installation

[](#installation)

This project assumes you have composer installed. Simply add new dependency via Composer:

```
composer require bordercloud/sparql
```

To your composer.json, and then you can simply install with:

```
composer install
```

### Test the lib with a php script : query

[](#test-the-lib-with-a-php-script--query)

You can test your first query sparql with DBPEDIA via a command line :

```
./bin/query -r -e http://dbpedia.org/sparql -f ./example/queryReadDBpedia.rq
```

And the doc of this script with virtuoso, 4store, Allegrograph, Fuseki and Sesame :

```
USAGE : query [-r|-w][-e URL|--endpointQueryAndUpdate=URL]
		[--file=FILE|-f FILE]
        [-v|-verbose]

    -r                                  READ ONLY
    -w                                  WRITE ONLY
    -e, --endpointQueryAndUpdate=URL    Put url of endpoint to do query or
                                        update :
                                            URL/sparql/?query=...
                                            URL/update/?update=... (POST)
    -q, --endpointQueryOnly=URL         Put url of endpoint to do query :
                                            URL?query=...
    -u, --endpointUpdateOnly=URL        Put url of endpoint to do query :
                                            URL?update=... (POST)
    --nameParameterQuery=PARAMETER      Change the name of parameter in
                                        the request http to read.
                                        (by default : query)
    --nameParameterUpdate=PARAMETER     Change the name of parameter in
                                        the request http to write.
                                        (by default : update)
    -f,--file=File                      File of the query.
    -t, --typeOutput=TYPE               Type of response: table,txt,csv,tsv,ttl,srx,srj
                                        (by default : table)

    -l, --login=LOGIN                  Server login
    -p, --password=PASSWORD            Server password

    -v, --verbose                       Mode verbose
    -d, --debug                         Mode debug

EXAMPLE : Virtuoso
./query -w -e http://localhost/tests/ -f ./example/queryWrite1.rq

./query -r -e http://localhost/tests/ -f ./example/queryRead1.rq

EXAMPLE : 4Store
./query -w -e http://localhost/ -f ./example/queryWrite1.rq

./query -r -e http://localhost/ -f ./example/queryRead1.rq

EXAMPLE : Sesame
./query -w -q http://localhost/openrdf-sesame/repositories/tests \
 -u http://localhost/openrdf-sesame/repositories/tests/statements \
-f ./example/queryWrite1.rq

./query -r -q http://localhost/openrdf-sesame/repositories/tests \
 -u http://localhost/openrdf-sesame/repositories/tests/statements \
-f ./example/queryRead1.rq

EXAMPLE : Fuseki
./query -w -q http://localhost/tests/query \
-u http://localhost/tests/update \
-f ./example/queryWrite1.rq

./query -r -q http://localhost/tests/query \
-u http://localhost/tests/update \
-f ./example/queryRead1.rq

EXAMPLE : Allegrograph
./query -w -q http://localhost/repositories/tests \
-u http://localhost/repositories/tests \
--nameParameterUpdate=query \
-f ./example/queryWrite1.rq

./query -r -q http://localhost/repositories/tests \
-u http://localhost/repositories/tests \
--nameParameterUpdate=query \
-f ./example/queryRead1.rq

```

### Examples

[](#examples)

Send a simple query to Wikidata :

```
