samwilson / simple-wikidata
A very simplistic library for interacting with Wikidata in PHP.
0.6.1
2019-07-21 01:47 UTC
Requires
- ext-json: *
- ext-simplexml: *
- addwiki/mediawiki-api-base: ^2.0
- mediawiki/oauthclient: ^1.0
- nayjest/str-case-converter: ^1.0
- psr/cache: ^1.0
- symfony/dom-crawler: ^4.0
Requires (Dev)
- mediawiki/mediawiki-codesniffer: ^26.0
- phpunit/phpunit: ^8.2
- symfony/var-dumper: ^4.3
- tedivm/stash: ^0.15
README
This is a simple (and limited, by design) package for interacting with Wikidata from PHP.
Example
// The Sparql must return an ?item column. $sparql = "SELECT ?item WHERE { ?item wdt:P31 wd:Q54050 } LIMIT 5"; $cache = new \Stash\Pool(new \Stash\Driver\FileSystem()); $people = new \Samwilson\SimpleWikidata\Query($sparql, 'en', $cache); foreach ($people->getItems() as $person) { // Each $person is an Item object. $person->getLabel(); $person->getPropertyOfTypeItem(); $person->getPropertyOfTypeQuantity(); $person->getPropertyOfTypeIdentifier(); // External identifier $person->getPropertyOfTypeUrl(); $person->getPropertyOfTypeTime(); $person->getPropertyOfTypeString(); // No language $person->getPropertyOfTypeText(); // Has language $person->getPropertyOfTypeCoord(); $person->getPropertyOfTypeFile(); // Commons media }
Licence
GPL3.0+