PHPackages                             taproot/micropub-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. taproot/micropub-adapter

ActiveLibrary[API Development](/categories/api)

taproot/micropub-adapter
========================

The easiest way to add micropub support to existing or new applications.

v0.1.3(2y ago)64731[1 issues](https://github.com/Taproot/micropub-adapter/issues)MITPHPPHP &gt;=7.3

Since Jun 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Taproot/micropub-adapter)[ Packagist](https://packagist.org/packages/taproot/micropub-adapter)[ RSS](/packages/taproot-micropub-adapter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (5)Used By (0)

taproot/micropub-adapter
========================

[](#taprootmicropub-adapter)

[![Latest Stable Version](https://camo.githubusercontent.com/e8b8d05d5a43a533a94f8d5502fc6d2b49237b55ff36bd67cecf1855b51d6559/687474703a2f2f706f7365722e707567782e6f72672f746170726f6f742f6d6963726f7075622d616461707465722f76)](https://packagist.org/packages/taproot/micropub-adapter) [![](https://github.com/taproot/micropub-adapter/actions/workflows/php.yml/badge.svg?branch=main)](https://github.com/Taproot/micropub-adapter/actions/workflows/php.yml) [![License](https://camo.githubusercontent.com/2ab396635c109d419272d9a9c4eef955bf32bb067184f806433b1ea107693f56/687474703a2f2f706f7365722e707567782e6f72672f746170726f6f742f6d6963726f7075622d616461707465722f6c6963656e7365)](https://packagist.org/packages/taproot/micropub-adapter) [![Total Downloads](https://camo.githubusercontent.com/f5075d5496fab012600a8c96498d195e07e15029c3ed928b601393f80b1096ae/687474703a2f2f706f7365722e707567782e6f72672f746170726f6f742f6d6963726f7075622d616461707465722f646f776e6c6f616473)](https://packagist.org/packages/taproot/micropub-adapter)

taproot/micropub-adapter is a simple and flexible way to add [Micropub](https://indieweb.org/Micropub) support to any PHP web app using PSR-7.

Quick Links
-----------

[](#quick-links)

- [API Documentation](https://taproot.github.io/micropub-adapter/namespaces/taproot-micropub.html)
- [Code Coverage](https://taproot.github.io/micropub-adapter/coverage/)
- [micropub.rocks implementation report](https://micropub.rocks/implementation-reports/servers/580/D3vyg58QCHfWI4TavNiT)

Installation
------------

[](#installation)

taproot/micropub-adapter is currently tested against and compatible with PHP 7.3, 7.4, 8.0 and 8.1.

Install taproot/micropub-adapter using [composer](https://getcomposer.org/):

```
composer.phar require taproot/micropub-adapter
composer.phar install (or composer.phar update)

```

Versioned releases are GPG signed so you can verify that the code hasn’t been tampered with.

```
gpg --recv-keys 1C00430B19C6B426922FE534BEF8CE58118AD524
cd vendor/taproot/micropub-adapter
git tag -v v0.1.3 # Replace with the version you have installed

```

Usage
-----

[](#usage)

### Subclassing MicropubAdapter

[](#subclassing-micropubadapter)

micropub-adapter defines an abstract class, [`Taproot\Micropub\MicropubAdapter`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html), which implements the request handling logic for micropub and micropub media endpoints. It parses incoming micropub requests and dispatches them to callback methods for each action (create, delete, update, etc.). It handles basic validation and error conditions, normalises incoming data for you, and converts return values from callback methods to valid responses.

All you need to do is subclass `MicropubAdapter` and implement the relevant callback methods for the actions you want to support. Then, in your app, make an instance of your adapter, and call `handleRequest()` and `handleMediaEndpointRequest()` within your micropub and media endpoint requests, respectively.

See [the example app](https://github.com/Taproot/micropub-adapter/tree/main/example) for an example of how to subclass and use `MicropubAdapter`.

#### Callback Methods

[](#callback-methods)

Refer to the API documentation for the paramters and possible return values of each callback. Optional callbacks have a default no-op implementation.

**Required** for any functionality:

- [`verifyAccessTokenCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_verifyAccessTokenCallback): this callback is responsible for validating the access token used to authorize micropub requests, and providing user/scope data for use in the other callbacks.

**Micropub endpoint action callbacks** — implement whichever are relevant for your use-case:

- [`configurationQueryCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_configurationQueryCallback)
- [`sourceQueryCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_sourceQueryCallback)
- [`createCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_createCallback)
- [`updateCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_updateCallback)
- [`deleteCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_deleteCallback)
- [`undeleteCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_undeleteCallback)

**Media Endpoint callbacks** — implement to enable the media endpoint. As routing is out of the scope of this library, you’ll have to add a `media-endpoint` value to the array returned by `configurationQueryCallback()` in order for clients to be able to discover the media endpoint.

- [`mediaEndpointCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_mediaEndpointCallback)

**Extension callbacks** — these are called after the incoming request is authenticated, but before any micropub-specific handling occurs. This allows your subclass to implement [micropub extensions](https://indieweb.org/Micropub-extensions). Implementations of these methods should check to see if a request requires extension handling (e.g. a `?q=source` request without a `url` parameter, which would return an error if handled by the logic surrounding `sourceQueryCallback()`). If the request requires extension handling, handle it and return a Response or error value. Otherwise, return `false` to continue handling the request as usual.

- [`extensionCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_extensionCallback)
- [`mediaEndpointExtensionCallback()`](https://taproot.github.io/micropub-adapter/classes/Taproot-Micropub-MicropubAdapter.html#method_mediaEndpointExtensionCallback)

### Access Tokens and IndieAuth

[](#access-tokens-and-indieauth)

You’ll need some way of verifying the access tokens used to authenticate micropub requests — indeed, `verifyAccessTokenCallback()` is the only method which you’re absolutely required to implement! If your app doesn’t yet have [IndieAuth](https://indieweb.org/IndieAuth) endpoints capable of creating and verifying access tokens, you may want to use the companion library [taproot/indieauth](https://github.com/taproot/indieauth/) to add indieauth support to your app. The example app uses taproot/indieauth, so you can refer to that for an example of how to use the two libraries together.

Contributing
------------

[](#contributing)

If you have any questions about using this library, join the [indieweb chatroom](https://indieweb.org/discuss) and ping `barnaby`.

If you find a bug or problem with the library, or want to suggest a feature, please [create an issue](https://github.com/Taproot/micropub-adapter/issues/new).

If discussions lead to you wanting to submit a pull request, following this process, while not required, will increase the chances of it quickly being accepted:

- Fork this repo to your own github account, and clone it to your development computer.
- Run `./run_coverage.sh` and ensure that all tests pass — you’ll need XDebug for code coverage data.
- If applicable, write failing regression tests e.g. for a bug you’re fixing.
- Make your changes.
- Run `./run_coverage.sh` and `open docs/coverage/index.html`. Make sure that the changes you made are covered by tests. taproot/micropub-adapter had 100% test coverage from version 0.1.0, and that number should never go down!
- Run `./vendor/bin/psalm` and and fix any warnings it brings up.
- Install and run `./phpDocumentor.phar` to regenerate the documentation if applicable.
- Push your changes and submit the PR.

Changelog
---------

[](#changelog)

### v0.1.3

[](#v013)

2023-07-24

- Handle JSON requests correctly when there is more than one `content-type` header — thanks @oddevan!

(0.1.2 missing due to tagging of incorrect commit)

### v0.1.1

[](#v011)

2022-10-03

- Updated example to use latest features from taproot/indieauth
- Allowed use of psr/log v2 and v3
- Allowed use of monolog v3 when testing
- Added PHP 8.1 to the test matrix, enabled manual dispatch.

### v0.1.0

[](#v010)

2021-06-24

Initial release.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~253 days

Total

4

Last Release

1029d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2568ed5219c714e13e09a9c63e84dbb674e629dade94fd5e115c7ffb0f9ee67?d=identicon)[barnabywalters](/maintainers/barnabywalters)

---

Top Contributors

[![barnabywalters](https://avatars.githubusercontent.com/u/968350?v=4)](https://github.com/barnabywalters "barnabywalters (59 commits)")[![oddevan](https://avatars.githubusercontent.com/u/1427716?v=4)](https://github.com/oddevan "oddevan (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/taproot-micropub-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/taproot-micropub-adapter/health.svg)](https://phpackages.com/packages/taproot-micropub-adapter)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69433.0M114](/packages/algolia-algoliasearch-client-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)[chartmogul/chartmogul-php

ChartMogul API PHP Client

181.4M](/packages/chartmogul-chartmogul-php)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
