Wikibase Query adds query capabilities to Wikibase Repo. It is part of the Wikibase software.
You can use Composer 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.
To add this package as a local, per-project dependency to your project, simply add a dependency on wikibase/query
to your project's composer.json
file. Here is a minimal example of a composer.json
file that just defines a dependency on Wikibase Query 1.0:
{ "require": { "wikibase/query": "1.0.*" } }
To get a list of available CLI commands, execute this in the root directory:
php querycli
All classes provided by WikibaseQuery reside in the Wikibase\Query namespace.
Public classes and interfaces have an @since tag denoting the version since which they can be accessed. Constructs without an @since tag are package private and should not be used by extensions.
Object graph construction is done via the dependency injection container defined in Wikibase\Query\DIC. Individual builders reside in Wikibase\Query\DIC\Builders. Builders are registered in Wikibase\Query\DIC\WikibaseQueryBuilder. All access to the DIC from outside the DIC happens via Wikibase\Query\DIC\WikibaseQuery. When requiring access to this class from a legacy API, the ExtensionAccess::getWikibaseQuery method should be used. Usage of this method is forbidden outside of legacy APIs in which we cannot achieve proper dependency construction.
This extension comes with a set up PHPUnit tests that cover all non-trivial code. The extension needs to be loaded via MediaWiki, after which the tests can be run via the MediaWiki test runner.
php phpunit.php -c ../../extensions/WikibaseQuery/
You might need to specify that MediaWiki should use normal tables
php phpunit.php -c ../../extensions/WikibaseQuery/ --use-normal-tables
If this does not work due to using PHPUnit 4.0 or later, you can temporarily modify your MediaWikis MediaWikiPHPUnitCommand.php
file.
Wikibase Query has been written by the Wikidata team for the Wikidata project. You can view the full list of contributors.