Download the PHP package effectiveactivism/sparql-client without Composer
On this page you can find all versions of the php package effectiveactivism/sparql-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download effectiveactivism/sparql-client
More information about effectiveactivism/sparql-client
Files in effectiveactivism/sparql-client
Package sparql-client
Short Description Provides a SparQl client.
License GPL-3.0-or-later
Homepage https://gitlab.com/effective-activism/sparql-client
Informations about the package sparql-client
SparQl client
An OOP SparQl 1.1 client for Symfony with support for SELECT, CONSTRUCT, DELETE, INSERT and DELETE+INSERT operations. Includes term, namespace and (basic) statement validation.
Table of content
- Installation
- Configuration
- Usage
- Select statement
- Limit, offset and order
- Construct statement
- Insert statement
- Delete statement
- Replace statement
- Property paths and sets
- Inverse path example
- Sequence path example
- Negated set example
- Assignment
- Bind example
- Values example
- Validation
- Optional clauses
- Service
- Constraints
- Filter examples
- Upload files
- Select statement
- SHACL validator
- Example docker-compose setup
- Planned features
Installation
To install, run
Configuration
This bundle requires a SparQl endpoint string. You can optionally define namespaces that should be included in every request. You can also optionally define a SHACL endpoint.
Usage
Select statement
Retrieve any subjects that have a schema:headline
of "Lorem"@la
.
Limit, offset and order
Select statements can use result modifiers:
Ask statement
Query whether a set of clauses has a solution:
Construct statement
Construct a set of triples:
Insert statement
Insert the following triple:
Delete statement
Delete all triples where the subject has the headline "lorem"@la
but only
if the subject has type schema:Article
.
Replace statement
Also known as DELETE+INSERT statements.
Replace all triples where a subject has a schema:headline
of "lorem"@la
with a schema:headline
of "ipsum"@la
.
Property paths and sets
To use path operators such as inverse path (^
), use the
EffectiveActivism\SparQlClient\Syntax\Term\Path
classes.
Inverse path example
Sequence path example
Negated set example
Assignment
Two assignment options are available: BIND and VALUES.
BIND example
VALUES example
To use UNDEF
in a VALUES expression, use null
. Value arrays must have
the same dimension as the variables array.
The above example will produce the following statement
Validation
This bundle supports validation of terms. For example, the below assignment will throw an InvalidArgumentException because the prefix contains illegal characters.
Namespaces are validated, both when defined in configuration (via sparql_client.yml) or added dynamically in code.
Rudimentary validation of statements is also supported. For example, the below statement will throw an InvalidArgumentException because the 'where' clause does not contain any of the requested variables.
Optional clauses
To add an optional clause, use the
EffectiveActivism\SparQlClient\Syntax\Optionally\Optionally
class.
Service
To use a service, use the
EffectiveActivism\SparQlClient\Syntax\Pattern\Service\Service
class.
The first parameter is the service IRI, while the second parameter is an array of patterns to use with the service.
Constraints
To apply a constraint, such as a filter, use the
EffectiveActivism\SparQlClient\Syntax\Constraint
classes.
To use an operator with the Filter()
class, use the
EffectiveActivism\SparQlClient\Syntax\Constraint\Operator
classes.
Filter examples
The example below showcase how to select all subjects that has a
schema:headline
value of lorem
except any subjects with a
schema:identifier
value of 13a5b1da-9060-11eb-a695-2bfde2d1d6bd
.
This example showcases how to use filter operators. Type enforcement ensures some argument validation.
Upload files
To upload a file containing a vocabulary, use the upload
method.
You must specify the content type of the file as the second parameter.
A default content type of application/x-turtle
is assumed.
SHACL validator
To use the validator service, define the SHACL validator endpoint. You can retrieve the SHACL client as a service. Insert, delete, replace and construct statements can be validated.
Example docker-compose setup
The docker services below showcase a working setup. This client has not been tested with other triplestores or validators.
The Blazegraph docker image requires no setup. To setup the isaitb SHACL validator, go here
Planned features
- Support for graphs, including named graphs and management operations.
- Support for DESCRIBE statements.
- Support for UNION.
- Support for empty prefixes.
- Validation of typed literals using their datatype.
- Improve error reporting from triplestores.
- Possibly return more meaningful data from INSERT and DELETE statement executions.
- Expand statement validation.
All versions of sparql-client with dependencies
doctrine/annotations Version ^1.12
psr/log Version ^3.0
ramsey/uuid Version ^4.1
symfony/config Version ^6.4|^7.0
symfony/dependency-injection Version ^6.4|^7.0
symfony/http-client Version ^6.4|^7.0
symfony/property-access Version ^6.4|^7.0
symfony/serializer Version ^6.4|^7.0
symfony/yaml Version ^6.4|^7.0