addwiki php libraries 3.0.0

October 23, 2021 0 By addshore

Back in 2014 I wrote a small collection of PHP libraries, releasing 2.0.0 of the base library in 2015 for interacting with MediaWiki and Wikibase. My goal back then was to create a stable base that PHP bot frameworks could be built on, while also experimenting with some framework like features in surrounding libraries.

And now, version 3.0.0 has been released, with a couple of new features, such as OAuth authentication, and lots of refactoring to make the libraries easier to work with and contribute to.

Library usage

I find it pretty hard to figure out how many people actually use these libraries and if it is worth keeping them updated, but there are a few notable projects that make use of them, particularly mediawiki-api-base which is a simple client wrapping Guzzle.

Packagist and Github metrics seem to hint that there is some usage. Though I suspect that the download numbers mainly come from usage in other projects CI setups.

PackageGithub StarsPackagist downloads in last 30 days
mediawiki-api-base331248 (41 a day)
mediawiki-api36745 (24 a day)
wikibase-api20103 (3 a day)

And I can easily hunt out some notable usages (even if some are mine):

So bring on a little refresh, in the form of version 3.0!

What’s changed for users?

The libraries now require PHP 7.4+ and have had typing added throughout.

All libraries have updated namespaces to follow PSR4. The base library uses the namespace Addwiki\Mediawiki\Api and which is shared by mediawiki-api which builds on top of it. The wikibase-api library takes the names space Addwiki\Wikibase etc.

The base library saw some additions such as a RestApi and OAuth authentication has been added to all APIs.

The simple username and password based auth has been replaced by an AuthMethod interface. This interface has a few implementations including UserAndPassword, UserAndPasswordWithDomain, NoAuth and OAuthOwnerConsumer. These can be used when creating an API service object to decide how to authenticate with it.

What’s changed for addwiki devs?

If you want to contribute to these libraries, you’ll now find that all development happens as part of a monorepo in addwiki/addwiki.

This should make contribution easier, as no complex inter library dependencies need to be thought of. This should also lead to making more releases as things are iteratively added or improved, as the release process is much simpiler.

For an overview of the workflows, make sure you read the README!