PHPackages                             your1/laravel-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. [Database &amp; ORM](/categories/database)
4. /
5. your1/laravel-sparql

ActiveLibrary[Database &amp; ORM](/categories/database)

your1/laravel-sparql
====================

A SPARQL based Eloquent model and Query builder for Laravel

1.2.14(3mo ago)1222MITPHPPHP ^8.2CI failing

Since Oct 24Pushed 3mo agoCompare

[ Source](https://github.com/YOUR1/laravel-sparql)[ Packagist](https://packagist.org/packages/your1/laravel-sparql)[ Docs](https://github.com/YOUR1/laravel-sparql)[ RSS](/packages/your1-laravel-sparql/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (26)Versions (24)Used By (0)

Laravel SPARQL
==============

[](#laravel-sparql)

A lean, production-ready **Laravel Eloquent adapter for SPARQL triple stores**. Query and manage RDF data using familiar Laravel patterns.

[![Tests](https://camo.githubusercontent.com/3ab4882a1b7d64e5eb5168ad0b0b9cdfd53f59f114ee5f727958504214a5789c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e737667)](tests)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Overview
--------

[](#overview)

Laravel SPARQL brings the power of RDF triple stores to Laravel with an Eloquent-style interface that feels native to Laravel developers. Built on the original Illuminate Database package by Taylor Otwell.

### Key Features

[](#key-features)

- **Familiar Eloquent API** - Use standard Laravel patterns like `where()`, `get()`, `first()`, `save()`, `delete()`
- **Analytical Queries (v1.2.3+)** - Build complex queries with custom SELECT expressions, BIND clauses, and GROUP BY
- **Hybrid Approach** - Scalars for single values, arrays for multi-values (no unnecessary Collections)
- **RDF Extensions** - Language tags, multi-valued properties, and URI mappings when you need them
- **Batch Operations** - Efficient bulk insert/update/delete operations
- **Sync Trait** - Easily sync regular Eloquent models to SPARQL endpoints
- **Multi-Tenancy Support** - Full support for stancl/tenancy with automatic endpoint switching per tenant
- **No Magic** - Explicit model definitions, no dynamic class generation
- **Production Ready** - 514 passing tests, optimized for performance

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12.0+
- A SPARQL 1.1 compliant endpoint with **Graph Store Protocol** support
    - ✅ Apache Jena Fuseki
    - ✅ Blazegraph
    - ✅ Amazon Neptune
    - ✅ GraphDB
    - ✅ Virtuoso
    - ✅ Most modern SPARQL stores

> **Note:** This package uses the W3C SPARQL 1.1 Graph Store HTTP Protocol for efficient bulk operations. This is a standard feature in modern SPARQL endpoints.

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

[](#installation)

Install via Composer:

```
composer require your1/laravel-sparql
```

The service provider will automatically register a `sparql` database driver with Laravel's database manager.

Quick Start
-----------

[](#quick-start)

### 1. Configure Your SPARQL Endpoint

[](#1-configure-your-sparql-endpoint)

Add to `config/database.php`:

```
'connections' => [
    'sparql' => [
        'driver' => 'sparql',
        'endpoint' => env('SPARQL_ENDPOINT', 'http://localhost:3030/test/sparql'),

        // IMPORTANT: Specify your triple store implementation
        'implementation' => env('SPARQL_IMPLEMENTATION', 'fuseki'),  // fuseki|blazegraph|generic

        'auth' => [
            'type' => 'digest',
            'username' => env('SPARQL_USERNAME'),
            'password' => env('SPARQL_PASSWORD'),
        ],
        'namespaces' => [
            'schema' => 'http://schema.org/',
            'foaf' => 'http://xmlns.com/foaf/0.1/',
        ],
    ],
],
```

**Implementation Options:**

- `fuseki` - Apache Jena Fuseki (default)
- `blazegraph` - Blazegraph triple store
- `generic` - W3C standard (Virtuoso, GraphDB, Stardog, Amazon Neptune, etc.)

Add to `.env`:

```
SPARQL_ENDPOINT=http://localhost:3030/test/sparql
SPARQL_IMPLEMENTATION=fuseki
```

### 2. Define a Model

[](#2-define-a-model)

```
use LinkedData\SPARQL\Eloquent\Model;

class Person extends Model
{
    protected $connection = 'sparql';
    protected $table = 'http://schema.org/Person';

    protected $propertyUris = [
        'name' => 'http://schema.org/name',
        'email' => 'http://schema.org/email',
        'age' => 'http://schema.org/age',
    ];

    protected $fillable = ['name', 'email', 'age'];
    protected $casts = ['age' => 'integer'];
}
```

### 3. Start Using It

[](#3-start-using-it)

```
// Create
$person = new Person();
$person->id = 'http://example.com/person/1';
$person->name = 'John Doe';
$person->email = 'john@example.com';
$person->save();

// Query
$adults = Person::where('age', '>', 18)->get();
$john = Person::where('name', 'John')->first();

// Update
$person->age = 31;
$person->save();

// Delete
$person->delete();

// Analytical queries (v1.2.3+)
use LinkedData\SPARQL\Query\Expression;

$labelStats = DB::connection('sparql')
    ->query()
    ->selectExpression('?language')
    ->selectExpression('(COUNT(?label) as ?count)')
    ->whereTriple('?concept', 'skos:inScheme', Expression::iri($schemeUri))
    ->whereTriple('?concept', 'skos:prefLabel', '?label')
    ->bind('COALESCE(LANG(?label), "no-lang")', '?language')
    ->groupBy('?language')
    ->get();
```

What's New in v1.2.3
--------------------

[](#whats-new-in-v123)

**Analytical Query Support** - Build sophisticated SPARQL queries with Laravel's fluent syntax:

- `selectExpression()` - Custom SELECT with aggregates and computed values
- `whereTriple()` - Explicit triple patterns with namespace support
- `bind()` - BIND expressions for computed values
- Enhanced `groupBy()` for SPARQL variables

See [Usage Guide - Analytical Queries](docs/USAGE.md#analytical-queries-v123) for examples.

Documentation
-------------

[](#documentation)

For comprehensive guides and examples, see:

- **[Usage Guide](docs/USAGE.md)** - Core concepts, CRUD operations, queries, RDF features, batch operations, and syncing regular Eloquent models
- **[Multi-Tenancy Guide](docs/TENANCY.md)** - Complete guide for integrating with stancl/tenancy for multi-tenant applications
- **[API Reference](docs/API.md)** - Complete API documentation for all classes and methods
- **[Development Guide](docs/DEVELOPMENT.md)** - Setup, testing, and development instructions

Philosophy
----------

[](#philosophy)

- **Simple is Better** - Minimal complexity, maximum clarity
- **No Magic** - Explicit over implicit, predictable behavior
- **Performance First** - Optimized for production workloads
- **Laravel Native** - Feels like standard Eloquent

Credits
-------

[](#credits)

**Original Author**: Roberto Guido - Created the foundational Laravel SPARQL adapter and maintained it as part of the Solid Data Workers project.

**Original Repository**:

**Original Licenses**: MIT License and Creative Commons Attribution 3.0 Unported

This fork preserves all original copyright and attribution while adding significant enhancements and modernizations.

Built on Laravel's Illuminate Database package by Taylor Otwell.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Support
-------

[](#support)

- **Issues**: [GitHub Issues](https://github.com/YOUR1/laravel-sparql/issues)
- **Discussions**: [GitHub Discussions](https://github.com/YOUR1/laravel-sparql/discussions)

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance81

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~29 days

Total

18

Last Release

103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2afbde5126c60557333240dff2896c67b055ab9786571431c7e647981e906c77?d=identicon)[YOUR1](/maintainers/YOUR1)

---

Top Contributors

[![YOUR1](https://avatars.githubusercontent.com/u/3681016?v=4)](https://github.com/YOUR1 "YOUR1 (27 commits)")[![madbob](https://avatars.githubusercontent.com/u/166089?v=4)](https://github.com/madbob "madbob (15 commits)")[![lucaslasota](https://avatars.githubusercontent.com/u/47364143?v=4)](https://github.com/lucaslasota "lucaslasota (1 commits)")

---

Tags

laraveldatabasemodeleloquentRDFmulti-tenancysparql

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/your1-laravel-sparql/health.svg)

```
[![Health](https://phpackages.com/badges/your1-laravel-sparql/health.svg)](https://phpackages.com/packages/your1-laravel-sparql)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
