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

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

queryr/entity-store
===================

Provides persistence and basic lookup capabilities for collections of Wikibase entities

1.1.0(9y ago)0351GPL-2.0+PHPPHP &gt;=5.5.0

Since May 15Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (9)Versions (16)Used By (0)

QueryR EntityStore
==================

[](#queryr-entitystore)

[![Build Status](https://camo.githubusercontent.com/ffed1521ac5ad7cf7bbe601096eebc9b5095eb9435c0e8d392ccff26d52440c0/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f4a65726f656e4465446175772f456e7469747953746f72652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/JeroenDeDauw/EntityStore)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/62d5d9ca0fc23d9258c9189c7b4817c14feb315a5d5e824d20cd01ae11aee8c7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a65726f656e4465446175772f456e7469747953746f72652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JeroenDeDauw/EntityStore/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/2c08605accf763dc38df993672be2c37a07f08d9fdce95d5f151020e5921d29f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a65726f656e4465446175772f456e7469747953746f72652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JeroenDeDauw/EntityStore/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/c48cb84ec5b793906f0d0f401ca0ccd0f1937c26c3340d57d5a0ae7e1359f8a2/68747470733a2f2f706f7365722e707567782e6f72672f7175657279722f656e746974792d73746f72652f76657273696f6e2e706e67)](https://packagist.org/packages/queryr/entity-store)[![Download count](https://camo.githubusercontent.com/e59b734deeedb6c8f0736954ec240228bab5c0b329ca38030dbe2f10e6b747f9/68747470733a2f2f706f7365722e707567782e6f72672f7175657279722f656e746974792d73746f72652f642f746f74616c2e706e67)](https://packagist.org/packages/queryr/entity-store)

Provides persistence and basic lookup capabilities for collections of [Wikibase](http://wikiba.se) entities.

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/entity-store` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on EntityStore 1.x:

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

Usage
-----

[](#usage)

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

All services are constructed via the `EntityStoreFactory` class:

```
use Queryr\EntityStore\EntityStoreFactory;
$factory = new EntityStoreFactory(
	$dbalConnection,
	new EntityStoreConfig( /* optional config */ )
);
```

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

### Writing values

[](#writing-values)

For writing values, you will need either `ItemStore` or `PropertyStore`.

```
$itemStore = $factory->newItemStore();
$propertyStore = $factory->newPropertyStore();
```

The main write methods are "store document" and "remove document by id".

```
$itemStore->storeItemRow( $itemRow );
$itemStore->deleteItemById( $itemId );
```

Note that `$itemRow` is of type `ItemRow`, which is defined by this component. `ItemRow` represents all values in a row of the items table. It does not require having a fully instantiated Wikibase DataModel `EntityDocument` object, you just need the JSON.

Next to `ItemRow` there also is `ItemInfo`, which is identical, apart for not having the JSON. (Internally these share code via the package private trait `ItemRowInfo`.)

### Querying values

[](#querying-values)

This list is incomplete and serves mainly to give you an idea of what this library contains. To get a full list, look at the services you can construct via the store, and their interfaces.

**Fetching an Item by id**

```
$q42 = $itemStore->getItemRowByNumericItemId( 42 );
```

**Property data type lookup**

```
$lookup = $factory->newPropertyTypeLookup();
$propertyType = $lookup->getTypeOfProperty( $propertyId );
```

**List item info**

Get cheaply retrievable info on the first 100 items.

```
$itemInfoList = $itemStore->getItemInfo( 100, 0 );
```

Restrict the result to items of type "book", assuming 424242 is the numeric id of "book".

```
$itemInfoList = $itemStore->getItemInfo( 100, 0, 424242 );
```

**List item types**

This will get you numeric item ids that represent the types of the items ("instance of") in the system.

```
$itemTypes = $itemStore->getItemTypes();
```

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.1.0 (2017-02-28)

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

- Added support for Wikibase DataModel 6.x and 5.x

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

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

- Added support for Wikibase DataModel 4.x and 3.x
- 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.6.2 (2014-12-24)

[](#version-062-2014-12-24)

- Wikibase DataModel 1.x is no longer supported
- Added `ItemStore::getIdForEnWikiPage`

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

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

- Allow installation together with DataModel 2.x

### Version 0.6.0 (2014-10-03)

[](#version-060-2014-10-03)

- Added `ItemStore::deleteItemById`
- Added `PropertyStore::deletePropertyById`
- Inserting an item or a property will now cause any older versions to be deleted
- The ItemStore now indexes the enwiki sitelink

### Version 0.5.4 (2014-09-08)

[](#version-054-2014-09-08)

- Added optional `$itemType` parameter to `ItemStore::getItemInfo`

### Version 0.5.3 (2014-09-06)

[](#version-053-2014-09-06)

- Added `InstanceOfTypeExtractor` implementation of `ItemTypeExtractor`

### Version 0.5.2 (2014-09-06)

[](#version-052-2014-09-06)

- Fixed item serialization bug in `ItemRowFactory`

### Version 0.5.1 (2014-09-06)

[](#version-051-2014-09-06)

- Added `ItemStore::getItemTypes`

### Version 0.5 (2014-09-06)

[](#version-05-2014-09-06)

- Removed the constructors of `ItemRow` and `ItemInfo`
- Added `item type` and `english label` fields to the items table
- Added `ItemRow::getItemInfo`
- Added `EntityPageInfo`
- Added `ItemRowFactory`. Construction of `ItemRow` should now be done via this class

### Version 0.4 (2014-08-27)

[](#version-04-2014-08-27)

- Added `EntityStoreFactory`
- Construction of `EntityStore` is now package private
- Added `ItemStore` and `PropertyStore`, both can be constructed via `EntityStoreFactory`
- Added `PropertyTypeLookup`, which can be constructed via `EntityStoreFactory::newPropertyTypeLookup`

### Version 0.3.1 (2014-08-20)

[](#version-031-2014-08-20)

- Added extra method level docs for better type hinting

### Version 0.3 (2014-08-20)

[](#version-03-2014-08-20)

- `ItemRow` and `PropertyRow` are now in `Queryr\EntityStore\Rows`
- Changed the constructor signatures of `ItemRow` and `PropertyRow`
- All `EntityStore` methods now throw exceptions of type `EntityStoreException`
- Added `EntityStoreException`
- Added `PropertyInfo` and `ItemInfo`
- Added `getPropertyInfo` and `getItemInfo` to `EntityStore`

### Version 0.2 (2014-06-29)

[](#version-02-2014-06-29)

- Renamed package from `queryr/dump-store` to `queryr/entity-store`
- Renamed `Store` class to `EntityStore`
- Renamed `StoreInstaller` class to `EntityStoreInstaller`
- `EntityStore` now requires an instance of `EntityStoreConfig` in its constructor
- `EntityStoreInstaller` now requires an instance of `EntityStoreConfig` in its constructor

### Version 0.1 (2014-05-15)

[](#version-01-2014-05-15)

- Initial release

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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 ~73 days

Recently: every ~219 days

Total

15

Last Release

3365d ago

Major Versions

0.6.2 → 1.0.02015-11-03

### 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 (80 commits)")

---

Tags

lookupwikibaseFingerprinttermsDataModel

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/queryr-entity-store/health.svg)](https://phpackages.com/packages/queryr-entity-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)[wikibase/data-model-serialization

Serializers and deserializers for the Wikibase DataModel

10196.3k8](/packages/wikibase-data-model-serialization)[lecturize/laravel-taxonomies

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

10310.5k](/packages/lecturize-laravel-taxonomies)

PHPackages © 2026

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