PHPackages                             effectiveactivism/sparql-client - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. effectiveactivism/sparql-client

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

effectiveactivism/sparql-client
===============================

Provides a SparQl client.

14.2.1(1mo ago)07701[1 PRs](https://github.com/EffectiveActivism/sparql-client/pulls)2GPL-3.0-or-laterPHPPHP ^8.1

Since Mar 15Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/EffectiveActivism/sparql-client)[ Packagist](https://packagist.org/packages/effectiveactivism/sparql-client)[ Docs](https://gitlab.com/effective-activism/sparql-client)[ RSS](/packages/effectiveactivism-sparql-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (68)Used By (2)

SparQl client
=============

[](#sparql-client)

An OOP SPARQL 1.1 client for Symfony with support for SELECT, CONSTRUCT, ASK, DESCRIBE, DELETE, INSERT and DELETE+INSERT operations. Includes graph patterns, aggregates, scalar functions, dataset clauses, and term, namespace and statement validation.

Table of content
----------------

[](#table-of-content)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Select statement](#select-statement)
        - [Limit, offset and order](#limit-offset-and-order)
        - [Distinct and reduced](#distinct-and-reduced)
        - [Group by and having](#group-by-and-having)
        - [Expressions](#expressions)
        - [Dataset clauses](#dataset-clauses)
    - [Ask statement](#ask-statement)
    - [Construct statement](#construct-statement)
    - [Insert statement](#insert-statement)
    - [Delete statement](#delete-statement)
    - [Replace statement](#replace-statement)
    - [Describe statement](#describe-statement)
    - [Graph patterns](#graph-patterns)
    - [Union](#union)
    - [Subquery](#subquery)
    - [Property paths and sets](#property-paths-and-sets)
        - [Inverse path example](#inverse-path-example)
        - [Sequence path example](#sequence-path-example)
        - [Negated set example](#negated-set-example)
    - [Assignment](#assignment)
        - [Bind example](#bind-example)
        - [Values example](#values-example)
    - [Validation](#validation)
    - [Optional clauses](#optional-clauses)
    - [Service](#service)
    - [Constraints](#constraints)
        - [Filter examples](#filter-examples)
    - [Aggregates](#aggregates)
    - [Error handling](#error-handling)
- [SHACL validator](#shacl-validator)
- [Example docker-compose setup](#example-docker-compose-setup)

Installation
------------

[](#installation)

To install, run

```
composer require effectiveactivism/sparql-client
```

Configuration
-------------

[](#configuration)

This bundle requires two SPARQL endpoints: one for query operations (SELECT, ASK, CONSTRUCT, DESCRIBE) and one for update operations (INSERT, DELETE, CLEAR, DROP, CREATE, REPLACE). You can also optionally define a SHACL endpoint.

For Blazegraph, both endpoints are the same URL:

```
sparql_client:
  query_endpoint: http://blazegraph:9999/blazegraph/sparql
  update_endpoint: http://blazegraph:9999/blazegraph/sparql
  shacl_endpoint: http://test-validator-endpoint/shacl/myshapes/api/validate
```

For Oxigraph, use the separate `/query` and `/update` paths:

```
sparql_client:
  query_endpoint: http://oxigraph:7878/query
  update_endpoint: http://oxigraph:7878/update
  shacl_endpoint: http://test-validator-endpoint/shacl/myshapes/api/validate
```

Usage
-----

[](#usage)

### Select statement

[](#select-statement)

Retrieve any subjects that have a `schema:headline` of `"Lorem"@la`.

```
