PHPackages                             queryr/term-store - 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. queryr/term-store

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

queryr/term-store
=================

Persistence of Wikibase terms with lookups of those terms and by those terms

1.3.0(8y ago)03511[2 issues](https://github.com/JeroenDeDauw/TermStore/issues)GPL-2.0+PHPPHP &gt;=7.1

Since Jun 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/JeroenDeDauw/TermStore)[ Packagist](https://packagist.org/packages/queryr/term-store)[ Docs](https://github.com/JeroenDeDauw/TermStore)[ RSS](/packages/queryr-term-store/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (10)Used By (0)

QueryR TermStore
================

[](#queryr-termstore)

[![Build Status](https://camo.githubusercontent.com/963cedecdde6aed03e8c1145f73e94b405b94ab34feb43e201abcb04b07a023e/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f4a65726f656e4465446175772f5465726d53746f72652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/JeroenDeDauw/TermStore)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/cb2068811e44a85db0ad9188c3b8c157af49e55174433de0939705df441a0da4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a65726f656e4465446175772f5465726d53746f72652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JeroenDeDauw/TermStore/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e365c99e1238c015479e11441fee242a0e66a67ab887285609e67051c40f22ae/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a65726f656e4465446175772f5465726d53746f72652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JeroenDeDauw/TermStore/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/7a46ff8f96694a356490d9ec6d953739945e6dd19aff89304ae13ec96dab18f7/68747470733a2f2f706f7365722e707567782e6f72672f7175657279722f7465726d2d73746f72652f76657273696f6e2e706e67)](https://packagist.org/packages/queryr/term-store)[![Download count](https://camo.githubusercontent.com/3eac95c8f946b7985187ebfd2ee2abd76a60b440d26d47751971c7fae8a740fa/68747470733a2f2f706f7365722e707567782e6f72672f7175657279722f7465726d2d73746f72652f642f746f74616c2e706e67)](https://packagist.org/packages/queryr/term-store)

Stores terms of [Wikibase](http://wikiba.se) entities to facilitate

- lookup of EntityIds given a term
- lookup of term(s) given an EntityId
- storing a Fingerprint for an EntityId
- removing all terms associated with an EntityId

System dependencies
-------------------

[](#system-dependencies)

- PHP 5.5 or later (PHP 7 and HHVM are supported)
- php5-sqlite (only needed for running the tests)

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

[](#installation)

To add this package as a local, per-project dependency to your project, simply add a dependency on `queryr/term-store` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on TermStore 1.x:

```
{
    "require": {
        "queryr/term-store": "~1.0"
    }
}
```

Usage
-----

[](#usage)

If you are curious what the database schema is, look at `src/TermStoreInstaller.php`.

All services are constructed via the `TermStoreFactory` class:

```
use Queryr\TermStore\TermStoreFactory;
$factory = new TermStoreFactory(
	$dbalConnection,
	new TermStoreConfig( /* optional config */ )
);
```

`$dbalConnection` is a `Connection` object from [Doctrine DBAL](https://github.com/doctrine/dbal).

### Writing to the store

[](#writing-to-the-store)

```
$writer = $factory->newTermStoreWriter();

$writer->storeEntityFingerprint( $entityId, $fingerprint );
$writer->dropTermsForId( $entityId );
```

### Lookup up an EntityId based on terms

[](#lookup-up-an-entityid-based-on-terms)

```
$idLookup = $factory->newEntityIdLookup();

$idLookup->getItemIdByLabel( $languageCode, $labelText );
$idLookup->getItemIdByText( $languageCode, $termText );
$idLookup->getIdByLabel( $languageCode, $labelText );
```

See the `EntityIdLookup` interface for all methods and their documentation.

### Lookup label based on EntityId and language

[](#lookup-label-based-on-entityid-and-language)

```
$labelLookup = $factory->newLabelLookup();
$labelLookup->getLabelByIdAndLanguage( $entityId, $languageCode );
```

See the `LabelLookup` interface for documentation.

Running the tests
-----------------

[](#running-the-tests)

For tests only

```
composer test

```

For style checks only

```
composer cs

```

For a full CI run

```
composer ci

```

Release notes
-------------

[](#release-notes)

### Version 1.3.0 (2018-01-04)

[](#version-130-2018-01-04)

- Bumped minimum PHP version to 7.1
- Added scalar and return type hints

### Version 1.2.0 (2017-02-28)

[](#version-120-2017-02-28)

- Installation with Wikibase DataModel 6.x is now allowed
- Installation with Wikibase DataModel 5.x is now allowed

### Version 1.1.0 (2015-11-10)

[](#version-110-2015-11-10)

- Added `newLabelLookup` to `TermStoreFactory`
- Improved documentation

### Version 1.0.0 (2015-11-03)

[](#version-100-2015-11-03)

- Installation with Wikibase DataModel 4.x is now allowed
- Installation with Wikibase DataModel 3.x is now allowed
- Changed minimum Wikibase DataModel version to 2.5
- Added ci command that runs PHPUnit, PHPCS, PHPMD and covers tags validation
- Added TravisCI and ScrutinizerCI integration

### Version 0.2.2 (2014-10-21)

[](#version-022-2014-10-21)

- Installation with Wikibase DataModel 2.x is now allowed

### Version 0.2.1 (2014-10-05)

[](#version-021-2014-10-05)

- Improved performance of `TermStore::storeEntityFingerprint` via usage of a transaction

### Version 0.2 (2014-09-11)

[](#version-02-2014-09-11)

- Added `TermStoreFactory`. Service construction should now happen via this factory
- Added `EntityIdLookup`, which is now implemented by `TermStore`
- Added `getItemIdByLabel`, `getPropertyIdByLabel`, `getItemIdByText` and `getPropertyIdByText` to `TermStore`

### Version 0.1 (2014-06-23)

[](#version-01-2014-06-23)

- Initial release

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~161 days

Recently: every ~198 days

Total

9

Last Release

3057d ago

Major Versions

0.2.3 → 1.0.02015-11-03

PHP version history (2 changes)0.1PHP &gt;=5.5.0

1.3.0PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (60 commits)")

---

Tags

lookupwikibaseFingerprinttermsDataModel

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/queryr-term-store/health.svg)

```
[![Health](https://phpackages.com/badges/queryr-term-store/health.svg)](https://phpackages.com/packages/queryr-term-store)
```

###  Alternatives

[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[lecturize/laravel-taxonomies

Simple, nestable Terms &amp; Taxonomies (similar to WordPress) for Laravel.

10310.5k](/packages/lecturize-laravel-taxonomies)[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)
