PHPackages                             sofe/infoapi - 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. sofe/infoapi

ActiveLibrary[API Development](/categories/api)

sofe/infoapi
============

1.2.1(4y ago)32334[3 issues](https://github.com/SOF3/InfoAPI/issues)Apache-2.0PHPCI failing

Since Dec 19Pushed 1y ago4 watchersCompare

[ Source](https://github.com/SOF3/InfoAPI)[ Packagist](https://packagist.org/packages/sofe/infoapi)[ RSS](/packages/sofe-infoapi/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (6)Used By (0)

InfoAPI
=======

[](#infoapi)

Extensible templating for PocketMine plugins.

In a nutshell, InfoAPI provides a simple API to register placeholders between plugins. But it is more powerful than just that:

- Object-oriented placeholder expressions
- Continuously update a template when variables change
- Parametric infos — mathematical operations on info expressions

Developer guide: Templating
---------------------------

[](#developer-guide-templating)

If you let users customize messages in a config, you can consider formatting the message with InfoAPI.

Pass the config message into InfoAPI:

```
use SOFe\InfoAPI;

// $this is the plugin main
$player->sendMessage(InfoAPI::render($this, $this->getConfig()->get("format"), [
    "arg" => $arg,
], $player));
```

- "message" is the config key for the message template
- The args array are the base variables for the template. The types of the variables must be one of the default types or provided by another plugin through `InfoAPI::addKind`.
- `$player` is optional. It tells InfoAPI how to localize the message better, e.g. by formatting for the player's language.

### Advanced: Continuous templating

[](#advanced-continuous-templating)

You can create a template and watch for changes using the `renderContinuous` API:

```
use SOFe\AwaitGenerator\Await;
use SOFe\InfoAPI;

Await::f2c(function() use($player) {
    $traverser = InfoAPI::renderContinuous($this, $this->getConfig()->get("format"), [
        "arg" => $arg,
    ], $player);

    while(yield from $traverser->next($message)) {
        $player->sendPopup($message);
    }
});
```

Developer guide: Register mapping
---------------------------------

[](#developer-guide-register-mapping)

A mapping converts one info to another, e.g. `money` converts a player to the amount of money in `{player money}`. You can register your own mappings so that your plugin as well as other plugins using InfoAPI can use this info in the template.

For example, to provide the money of an online player:

```
InfoAPI::addMapping(
    $this, "myplugin.money",
    fn(Player $player) : ?int => $this->getMoney($player),
);
```

The source and return types must be a default or `InfoAPI::addKind` types.

### Advanced: Register continuous mapping

[](#advanced-register-continuous-mapping)

You can additionally provide a `watchChanges` closure, which returns a [traverser](https://sof3.github.io/await-generator/master/async-iterators.html)that yields a value when a change is detected. The [pmevent](https://github.com/SOF3/pmevent) library may help with building traversers from events:

```
InfoAPI::addMapping(
    $this, "myplugin.money",
    fn(Player $player) : ?int => $this->getMoney($player),
    watchChanges: fn(Player $player) => Events::watch(
        $this, MoneyChangeEvent::class, $player->getName(),
        fn(MoneyChangeEvent $event) => $event->getPlayer()->getName(),
    )->asGenerator(),
);
```

Developer guide: Install InfoAPI
--------------------------------

[](#developer-guide-install-infoapi)

> If you are not developing a plugin, you do **not** need to install InfoAPI yourself. Plugins should have included InfoAPI in their phar release.

InfoAPI v2 is a virion library using virion 3.1. Virion 3.1 uses composer to install libraries:

1. Include the InfoAPI virion by adding sof3/infoapi in your composer.json:

```
{
  "require": {
    "sof3/infoapi": "^2"
  }
}
```

You can place this file next to your plugin.yml. Installing composer is recommended but not required.

2. Build your plugin with the InfoAPI virion using [pharynx](https://github.com/SOF3/pharynx). You can test it on a server using the custom start.cmd/start.sh provided by pharynx.
3. Use the [pharynx GitHub action](https://github.com/SOf3/timer-pmmp/blob/master/.github/workflows/ci.yml)to integrate with Poggit. Remember to gitignore your vendor directory so that you don't push it to GitHub.

User guide: Writing a template
------------------------------

[](#user-guide-writing-a-template)

InfoAPI replaces expressions inside `{}` with variables. For example, if a chat plugin provides two variables:

- `sender`: the player who sent chat (SOFe)
- `message`: the chat message the following will become something like ` Hello world`if the plugin provides `sender` and `message` ("Hello world")for the template:

```
 {message}

```

Color codes are default variables. Instead of writing §1 §b etc, you could also write:

```
{aqua} {white}{message}

```

You can get more detailed info for a variable. For example, to get the coordinates of a player `player`:

```
{player} is at ({player x}, {player y}, {player z}).

```

Writing `{` directly will cause error without a matching `}`. If you want to write a `{`/`}` that is not part of an expression, write twice instead:

```
hello {{world}}.

```

This will become

```
hello {world}.

```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.7% 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 ~201 days

Total

4

Last Release

1007d ago

Major Versions

1.2.1 → 2.0.0-beta.12023-08-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2801890?v=4)[SOFe](/maintainers/SOFe)[@sofe](https://github.com/sofe)

---

Top Contributors

[![SOF3](https://avatars.githubusercontent.com/u/19623715?v=4)](https://github.com/SOF3 "SOF3 (138 commits)")[![Endermanbugzjfc](https://avatars.githubusercontent.com/u/53002741?v=4)](https://github.com/Endermanbugzjfc "Endermanbugzjfc (19 commits)")[![JaxkDev](https://avatars.githubusercontent.com/u/25908768?v=4)](https://github.com/JaxkDev "JaxkDev (6 commits)")[![JavierLeon9966](https://avatars.githubusercontent.com/u/58715544?v=4)](https://github.com/JavierLeon9966 "JavierLeon9966 (1 commits)")[![Aboshxm2](https://avatars.githubusercontent.com/u/72500560?v=4)](https://github.com/Aboshxm2 "Aboshxm2 (1 commits)")[![Mcbeany](https://avatars.githubusercontent.com/u/77101686?v=4)](https://github.com/Mcbeany "Mcbeany (1 commits)")[![Nerahikada](https://avatars.githubusercontent.com/u/15967582?v=4)](https://github.com/Nerahikada "Nerahikada (1 commits)")[![poggit-bot](https://avatars.githubusercontent.com/u/22427965?v=4)](https://github.com/poggit-bot "poggit-bot (1 commits)")[![armorshard1](https://avatars.githubusercontent.com/u/202433812?v=4)](https://github.com/armorshard1 "armorshard1 (1 commits)")

---

Tags

phppocketmine-plugin

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sofe-infoapi/health.svg)

```
[![Health](https://phpackages.com/badges/sofe-infoapi/health.svg)](https://phpackages.com/packages/sofe-infoapi)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)

PHPackages © 2026

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