queryr / entity-store
Provides persistence and basic lookup capabilities for collections of Wikibase entities
Installs: 349
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/queryr/entity-store
Requires
- php: >=5.5.0
- ext-pdo: *
- doctrine/dbal: ~2.5
- serialization/serialization: ~3.2
- wikibase/data-model: ~6.0|~5.0|~4.0|~3.0|~2.5
Requires (Dev)
- ext-pdo_sqlite: *
- jeroen/wikibase-data-fixtures: ~1.0|0.x,>=0.2.3
- ockcyp/covers-validator: ~0.4.0
- phpmd/phpmd: ~2.3
- phpunit/phpunit: ~5.3.0|~4.8
- squizlabs/php_codesniffer: ~2.3
- whatthejeff/nyancat-phpunit-resultprinter: ~1.2
README
Provides persistence and basic lookup capabilities for collections of Wikibase entities.
System dependencies
- PHP 5.5 or later (PHP 7 and HHVM are supported)
- php5-sqlite (only needed for running the tests)
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
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.
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
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
For tests only
composer test
For style checks only
composer cs
For a full CI run
composer ci
Release notes
Version 1.1.0 (2017-02-28)
- Added support for Wikibase DataModel 6.x and 5.x
Version 1.0.0 (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)
- Wikibase DataModel 1.x is no longer supported
- Added
ItemStore::getIdForEnWikiPage
Version 0.6.1 (2014-10-21)
- Allow installation together with DataModel 2.x
Version 0.6.0 (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)
- Added optional
$itemTypeparameter toItemStore::getItemInfo
Version 0.5.3 (2014-09-06)
- Added
InstanceOfTypeExtractorimplementation ofItemTypeExtractor
Version 0.5.2 (2014-09-06)
- Fixed item serialization bug in
ItemRowFactory
Version 0.5.1 (2014-09-06)
- Added
ItemStore::getItemTypes
Version 0.5 (2014-09-06)
- Removed the constructors of
ItemRowandItemInfo - Added
item typeandenglish labelfields to the items table - Added
ItemRow::getItemInfo - Added
EntityPageInfo - Added
ItemRowFactory. Construction ofItemRowshould now be done via this class
Version 0.4 (2014-08-27)
- Added
EntityStoreFactory - Construction of
EntityStoreis now package private - Added
ItemStoreandPropertyStore, both can be constructed viaEntityStoreFactory - Added
PropertyTypeLookup, which can be constructed viaEntityStoreFactory::newPropertyTypeLookup
Version 0.3.1 (2014-08-20)
- Added extra method level docs for better type hinting
Version 0.3 (2014-08-20)
ItemRowandPropertyRoware now inQueryr\EntityStore\Rows- Changed the constructor signatures of
ItemRowandPropertyRow - All
EntityStoremethods now throw exceptions of typeEntityStoreException - Added
EntityStoreException - Added
PropertyInfoandItemInfo - Added
getPropertyInfoandgetItemInfotoEntityStore
Version 0.2 (2014-06-29)
- Renamed package from
queryr/dump-storetoqueryr/entity-store - Renamed
Storeclass toEntityStore - Renamed
StoreInstallerclass toEntityStoreInstaller EntityStorenow requires an instance ofEntityStoreConfigin its constructorEntityStoreInstallernow requires an instance ofEntityStoreConfigin its constructor
Version 0.1 (2014-05-15)
- Initial release