PHPackages                             wikibase/query-engine - 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. wikibase/query-engine

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

wikibase/query-engine
=====================

Answers Ask queries against a collection of Wikibase entities

0.3.1(11y ago)12.3kGPL-2.0+PHPPHP &gt;=5.3.0

Since May 3Pushed 8y ago18 watchersCompare

[ Source](https://github.com/wmde/WikibaseQueryEngine)[ Packagist](https://packagist.org/packages/wikibase/query-engine)[ Docs](https://github.com/wmde/WikibaseQueryEngine)[ RSS](/packages/wikibase-query-engine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (8)Used By (0)

WMDE has stopped development of this component. A fork with further development work done on it can be found at [jeroen/query-engine](https://github.com/JeroenDeDauw/WikibaseQueryEngine).

Wikibase QueryEngine
====================

[](#wikibase-queryengine)

[![Build Status](https://camo.githubusercontent.com/d4a76ef85555a87a95574523837730236341a2cdea864e7ed0612b0d5af83690/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f776d64652f57696b69626173655175657279456e67696e652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/wmde/WikibaseQueryEngine)[![Code Coverage](https://camo.githubusercontent.com/7f38b51da8797ddba0539aab696064c58dd8925ce60c9d74ef8d5890d6cbf31a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776d64652f57696b69626173655175657279456e67696e652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wmde/WikibaseQueryEngine/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b94768c2688f5dcd89d8f7c22d57aca11f8d3a2fdd572064006ac80300657ccd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f776d64652f57696b69626173655175657279456e67696e652f6261646765732f7175616c6974792d73636f72652e706e673f733d36396362376134323732626164616665656138373632373563643664626131303332666132643436)](https://scrutinizer-ci.com/g/wmde/WikibaseQueryEngine/)[![Dependency Status](https://camo.githubusercontent.com/d3bf8d055512a6a02894511560da776a9b76e4d3285522459f052fc58b3d8679/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f77696b69626173653a71756572792d656e67696e652f6465762d6d61737465722f62616467652e737667)](https://www.versioneye.com/php/wikibase:query-engine/dev-master)

On [Packagist](https://packagist.org/packages/wikibase/query-engine): [![Latest Stable Version](https://camo.githubusercontent.com/060a35e0d0dd1666f94eb29640b973760ef2412de5a1ee19967721efc714cd92/68747470733a2f2f706f7365722e707567782e6f72672f77696b69626173652f71756572792d656e67696e652f76657273696f6e2e706e67)](https://packagist.org/packages/wikibase/query-engine)[![Download count](https://camo.githubusercontent.com/c254db55d7553bc79121a63f8068effdb79c2371b537006613f1d82627560d60/68747470733a2f2f706f7365722e707567782e6f72672f77696b69626173652f71756572792d656e67696e652f642f746f74616c2e706e67)](https://packagist.org/packages/wikibase/query-engine)

**Wikibase QueryEngine** is a component that supports running [Ask](https://github.com/wmde/Ask)queries against a collection of [Wikibase](http://wikiba.se) entities.

It is primarily used by the Wikibase MediaWiki extensions, though has no dependencies whatsoever on these or on MediaWiki itself.

Recent changes can be found in the [release notes](RELEASE-NOTES.md).

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

[](#installation)

You can use [Composer](http://getcomposer.org/) to download and install this package as well as its dependencies. Alternatively you can simply clone the git repository and take care of loading yourself.

### Composer

[](#composer)

To add this package as a local, per-project dependency to your project, simply add a dependency on `wikibase/query-engine` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Wikibase QueryEngine 1.0:

```
    {
        "require": {
            "wikibase/query-engine": "1.0.*"
        }
    }
```

### Manual

[](#manual)

Get the Wikibase QueryEngine code, either via git, or some other means. Also get all dependencies. You can find a list of the dependencies in the "require" section of the composer.json file. Load all dependencies and the load the Wikibase QueryEngine library by including its entry point: WikibaseQueryEngine.php.

Tests
-----

[](#tests)

This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run via TravisCI, as a TravisCI configuration file is also provided in the root directory.

Running the tests

```
phpunit

```

Usage
-----

[](#usage)

The public interfaces in this component are everything directly in the Wikibase\\QueryEngine. Other classes and interfaces are typically package private, and should not be used or known about outside of the package. Each store implementation has its own list of additional public classes.

### SQLStore

[](#sqlstore)

Public classes of the SQLStore:

Needed for construction:

- SQLStore\\SQLStore
    - SQLStore\\StoreSchema
        - SQLStore\\DataValueHandlers
    - SQLStore\\StoreConfig

Needed for extension:

- SQLStore\\DataValueHandler

Constructing an SQLStore:

```
use Wikibase\QueryEngine\SQLStore\SQLStore;
use Wikibase\QueryEngine\SQLStore\StoreSchema;
use Wikibase\QueryEngine\SQLStore\StoreConfig;
use Wikibase\QueryEngine\SQLStore\DataValueHandlers;
use Wikibase\QueryEngine\SQLStore\DVHandler\NumberHandler;

$dvHandlers = new DataValueHandlers();

$dvHandlers->addMainSnakHandler( 'number', new NumberHandler() );

$store = new Store(
    new StoreSchema( 'table_prefix_', $dvHandlers ),
    new StoreConfig( 'store name' )
);
```

CLI
---

[](#cli)

To get a list of available CLI commands, execute this in the root directory:

```
php queryengine

```

SQLStore internal structure
---------------------------

[](#sqlstore-internal-structure)

### Table: entities

[](#table-entities)

- id, string: serialization of the entities id
- type, string: type of the entity

### Snak tables

[](#snak-tables)

All snak tables have the following fields:

- row\_id, int
- subject\_id, string
- subject\_type, string
- property\_id, string
- statement\_rank, int

The schema definition is dynamically build in StoreSchema.php.

#### Value snak tables

[](#value-snak-tables)

There is a value snak table per type of data value the store is configured to support.

All data value tables have a set of additional fields that are specific to the type of data value they store. For the types of data value natively supported by the store.

#### Valueless snak tables

[](#valueless-snak-tables)

Additional fields:

- snak\_type, int: type of the snak, ie "no value"

Authors
-------

[](#authors)

Wikibase QueryEngine has been written by the Wikidata team for the [Wikidata project](https://wikidata.org/).

Links
-----

[](#links)

- [Wikibase QueryEngine on Packagist](https://packagist.org/packages/wikibase/query-engine)
- [Wikibase QueryEngine on Ohloh](https://www.ohloh.net/p/wikibasequeryengine/)
- [Wikibase QueryEngine on GitHub](https://github.com/wmde/WikibaseQueryEngine)
- [TravisCI build status](https://travis-ci.org/wmde/WikibaseQueryEngine)

Related projects
----------------

[](#related-projects)

- [Wikibase](http://wikiba.se)
- [Semantic MediaWiki](https://semantic-mediawiki.org/)

Bugs on Phabricator
-------------------

[](#bugs-on-phabricator)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.5% 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 ~28 days

Total

5

Last Release

4275d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/451bd4039d530fed8f9c3da91bfa519233a397d2182cdfdcad700f6cfea19b7f?d=identicon)[Jeroen De Dauw](/maintainers/Jeroen%20De%20Dauw)

![](https://www.gravatar.com/avatar/054adb441e7ee248ec924bc45fa793835c284710eb31627587fa5de21bab9e96?d=identicon)[wmde](/maintainers/wmde)

![](https://www.gravatar.com/avatar/5406ed1d40d50ffc61d67e9f5149914dbfe0b8a52bdf297299f5ccfab0a73d91?d=identicon)[thiemowmde](/maintainers/thiemowmde)

![](https://www.gravatar.com/avatar/fe4220e5a109212ea1a84969fbcb0795ceaf975145c1f0577bd758d0500e6428?d=identicon)[manicki](/maintainers/manicki)

![](https://www.gravatar.com/avatar/99b03312aa8fcf47db8cbde452192aa5b96c27d1b99c4c1fb22af92ae1dbb0fb?d=identicon)[filbertkm](/maintainers/filbertkm)

---

Top Contributors

[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (284 commits)")[![thiemowmde](https://avatars.githubusercontent.com/u/6576639?v=4)](https://github.com/thiemowmde "thiemowmde (99 commits)")[![addshore](https://avatars.githubusercontent.com/u/3308769?v=4)](https://github.com/addshore "addshore (31 commits)")[![translatewiki](https://avatars.githubusercontent.com/u/24829418?v=4)](https://github.com/translatewiki "translatewiki (13 commits)")[![mariushoch](https://avatars.githubusercontent.com/u/2446964?v=4)](https://github.com/mariushoch "mariushoch (8 commits)")[![tobijat](https://avatars.githubusercontent.com/u/2997252?v=4)](https://github.com/tobijat "tobijat (4 commits)")[![adrianheine](https://avatars.githubusercontent.com/u/139208?v=4)](https://github.com/adrianheine "adrianheine (3 commits)")[![JanZerebecki](https://avatars.githubusercontent.com/u/7452727?v=4)](https://github.com/JanZerebecki "JanZerebecki (2 commits)")[![frimelle](https://avatars.githubusercontent.com/u/2714560?v=4)](https://github.com/frimelle "frimelle (2 commits)")[![raymondde](https://avatars.githubusercontent.com/u/4243486?v=4)](https://github.com/raymondde "raymondde (1 commits)")

---

Tags

wikidatawikibaseQueryEngine

### Embed Badge

![Health badge](/badges/wikibase-query-engine/health.svg)

```
[![Health](https://phpackages.com/badges/wikibase-query-engine/health.svg)](https://phpackages.com/packages/wikibase-query-engine)
```

###  Alternatives

[data-values/data-values

Defines the DataValue interface and some trivial implementations

171.0M22](/packages/data-values-data-values)[data-values/geo

Geographical value objects, parsers and formatters

20631.0k18](/packages/data-values-geo)[data-values/number

Numerical value objects, parsers and formatters

18303.0k14](/packages/data-values-number)[wikibase/data-model

PHP implementation of the Wikibase DataModel

37243.3k23](/packages/wikibase-data-model)[data-values/time

Time value objects, parsers and formatters

10318.6k14](/packages/data-values-time)[wikibase/data-model-serialization

Serializers and deserializers for the Wikibase DataModel

10196.3k8](/packages/wikibase-data-model-serialization)

PHPackages © 2026

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