{"id":15134587,"url":"https://github.com/professionalwiki/sparql","last_synced_at":"2025-10-23T11:30:38.669Z","repository":{"id":204348357,"uuid":"711618592","full_name":"ProfessionalWiki/SPARQL","owner":"ProfessionalWiki","description":"MediaWiki extension to run SPARQL queries and template their results via Lua","archived":false,"fork":false,"pushed_at":"2025-01-19T22:19:51.000Z","size":56,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-30T17:43:37.731Z","etag":null,"topics":["lua","mediawiki","mediawiki-extension","scribunto","sparql","sparql-query","wikibase","wikibase-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProfessionalWiki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-29T20:03:48.000Z","updated_at":"2025-01-19T22:19:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"49b985b2-79a6-4b89-b414-f186267ae14b","html_url":"https://github.com/ProfessionalWiki/SPARQL","commit_stats":null,"previous_names":["professionalwiki/sparql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FSPARQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FSPARQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FSPARQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProfessionalWiki%2FSPARQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProfessionalWiki","download_url":"https://codeload.github.com/ProfessionalWiki/SPARQL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237811556,"owners_count":19370149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","mediawiki","mediawiki-extension","scribunto","sparql","sparql-query","wikibase","wikibase-extension"],"created_at":"2024-09-26T05:23:07.045Z","updated_at":"2025-10-23T11:30:38.661Z","avatar_url":"https://github.com/ProfessionalWiki.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SPARQL\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ProfessionalWiki/SPARQL/ci.yml?branch=master)](https://github.com/ProfessionalWiki/SPARQL/actions?query=workflow%3ACI)\n[![Type Coverage](https://shepherd.dev/github/ProfessionalWiki/SPARQL/coverage.svg)](https://shepherd.dev/github/ProfessionalWiki/SPARQL)\n[![Psalm level](https://shepherd.dev/github/ProfessionalWiki/SPARQL/level.svg)](psalm.xml)\n[![Latest Stable Version](https://poser.pugx.org/professional-wiki/sparql/v/stable)](https://packagist.org/packages/professional-wiki/sparql)\n[![Download count](https://poser.pugx.org/professional-wiki/sparql/downloads)](https://packagist.org/packages/professional-wiki/sparql)\n[![License](https://poser.pugx.org/professional-wiki/sparql/license)](LICENSE)\n\nMediaWiki extension for executing SPARQL queries and templating their results via Lua.\n\n[Professional.Wiki] created and maintains SPARQL. We provide [Wikibase hosting],\n[Wikibase development], [MediaWiki development], and [Wikibase consulting].\n\n**Table of Contents**\n\n- [Usage](#usage-documentation)\n- [Installation](#installation)\n- [PHP Configuration](#php-configuration)\n- [Development](#development)\n- [Release notes](#release-notes)\n\n## Usage Documentation\n\nDefine a lua module that requires the `SPARQL` binding and uses its runQuery method.\n\nExample: create page `Module:MySPARQL`:\n\n```lua\nlocal sparql = require('SPARQL') -- Load the SPARQL binding\n\nlocal p = {}\n\nfunction p.showFirstValue(frame)\n  local sparqlQuery = frame.args[1]\n  local queryResults = sparql.runQuery(sparqlQuery) -- Use the runQuery method\n\n  local firstColName = queryResults['head']['vars'][0]\n  return queryResults['results']['bindings'][0][firstColName]['value']\n\nend\n\nreturn p\n```\n\nWhich can then be invoked via [Scribunto]'s normal mechanisms from within wikitext. Example:\n\n`{{#invoke:MySPARQL|showFirstValue|your SPARQL query here}}`\n\nLua module examples:\n\n* [Show the first value (README example)](demoLua/firstValue.lua)\n* [Show everything](demoLua/showEverything.lua)\n* [Build an HTML table](demoLua/htmlTable.lua)\n\n## Installation\n\nPlatform requirements:\n\n* [PHP] 8.1 or later (tested up to 8.3)\n* [MediaWiki] 1.39 or later (tested up to 1.43)\n* [Scribunto] and lua\n\nWe also recommend installing the [CodeEditor extension]\nfor a better editing experience of Lua modules.\n\n### Installing The SPARQL Extension\n\nThe recommended way to install the SPARQL extension is using [Composer] with\n[MediaWiki's built-in support for Composer][Composer install].\n\nOn the commandline, go to your wikis root directory. Then run these two commands:\n\n```shell script\nCOMPOSER=composer.local.json composer require --no-update professional-wiki/sparql:~1.0\n```\n\n```shell script\ncomposer update professional-wiki/sparql --no-dev -o\n```\n\nThen enable the extension by adding the following to the bottom of your wikis [LocalSettings.php] file:\n\n```php\nwfLoadExtension( 'SPARQL' );\n```\n\nYou can verify the extension was enabled successfully by opening your wikis Special:Version page.\n\n## PHP Configuration\n\nConfiguration can be changed via [LocalSettings.php].\n\n### SPARQL Endpoint URL\n\nVariable: `$wgSPARQLEndpoint`\n\nRequired for the extension to function. You can enable the extension without setting this variable without\nbreaking your wiki, but the extension will not work.\n\nExample:\n\n```php\n$wgSPARQLEndpoint = 'https://query.portal.mardi4nfdi.de/proxy/wdqs/bigdata/namespace/wdq/sparql';\n```\n\n## Development\n\nRun `composer install` in `extensions/SPARQL/` to make the code quality tools available.\n\n### Running Tests and CI Checks\n\nYou can use the `Makefile` by running make commands in the `SPARQL` directory.\n\n* `make ci`: Run everything\n* `make test`: Run all tests\n* `make phpunit --filter FooBar`: run only PHPUnit tests with FooBar in their name\n* `make phpcs`: Run all style checks\n* `make cs`: Run all style checks and static analysis\n\n### Updating Baseline Files\n\nSometimes Psalm and PHPStan generate errors or warnings we do not wish to fix.\nThese can be ignored by adding them to the respective baseline file. You can update\nthese files with `make stan-baseline` and `make psalm-baseline`.\n\n## Release Notes\n\n### Version 1.0.0 - 2023-11-24\n\n* Lua binding `SPARQL.runQuery` to execute SPARQL queries and return the results as a Lua table\n* Compatibility with MediaWiki 1.39, 1.40 and 1.41\n* Compatibility with PHP 8.1 and 8.2\n\n[Professional.Wiki]: https://professional.wiki\n[Wikibase]: https://wikibase.consulting/what-is-wikibase/\n[Wikibase hosting]: https://professional.wiki/en/hosting/wikibase\n[Wikibase development]: https://professional.wiki/en/wikibase-software-development\n[MediaWiki development]: https://professional.wiki/en/mediawiki-development\n[Wikibase consulting]: https://wikibase.consulting/\n[MediaWiki]: https://www.mediawiki.org\n[PHP]: https://www.php.net\n[Composer]: https://getcomposer.org\n[Composer install]: https://professional.wiki/en/articles/installing-mediawiki-extensions-with-composer\n[LocalSettings.php]: https://www.pro.wiki/help/mediawiki-localsettings-php-guide\n[Scribunto]: https://www.mediawiki.org/wiki/Extension:Scribunto\n[CodeEditor extension]: https://www.mediawiki.org/wiki/Extension:CodeEditor\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofessionalwiki%2Fsparql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprofessionalwiki%2Fsparql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofessionalwiki%2Fsparql/lists"}