2017 © Pedro Peláez
 

library simple-wikidata

image

samwilson/simple-wikidata

  • Sunday, October 29, 2017
  • by samwilson
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Simple Wikidata

This is a simple (and limited, by design) package for interacting with Wikidata from PHP., (*1)

Packagist License GitHub issues Scrutinizer Code Quality Code Coverage Build Status, (*2)

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+, (*3)

The Versions