PHPackages                             dev-lancer/minecraft-motd-parser - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. dev-lancer/minecraft-motd-parser

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

dev-lancer/minecraft-motd-parser
================================

PHP library to parse minecraft server motd

v1.0.7(1y ago)34.7k11MITPHPPHP &gt;=7.4

Since Mar 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jgniecki/MinecraftMotdParser)[ Packagist](https://packagist.org/packages/dev-lancer/minecraft-motd-parser)[ RSS](/packages/dev-lancer-minecraft-motd-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (12)Used By (1)Security (1)

Minecraft MOTD Parser
=====================

[](#minecraft-motd-parser)

[![](https://camo.githubusercontent.com/278530e423ee4ff4ed9999bc2383954bb30aec933742ea88df37ecdaed43471a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465762d6c616e6365722f6d696e6563726166742d6d6f74642d7061727365723f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/278530e423ee4ff4ed9999bc2383954bb30aec933742ea88df37ecdaed43471a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465762d6c616e6365722f6d696e6563726166742d6d6f74642d7061727365723f7374796c653d666f722d7468652d6261646765)[![](https://camo.githubusercontent.com/0173d76fa5996708169ba46c111b26587b0e090c52ea81e054203930ec944401/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465762d6c616e6365722f6d696e6563726166742d6d6f74642d7061727365723f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/0173d76fa5996708169ba46c111b26587b0e090c52ea81e054203930ec944401/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465762d6c616e6365722f6d696e6563726166742d6d6f74642d7061727365723f7374796c653d666f722d7468652d6261646765)[![](https://camo.githubusercontent.com/8c66d2ff1bec4825bf45c2bfe81bdb9a7dc561f20867121875d18d8b1597dcbf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a676e6965636b692f4d696e6563726166744d6f74645061727365723f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/8c66d2ff1bec4825bf45c2bfe81bdb9a7dc561f20867121875d18d8b1597dcbf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a676e6965636b692f4d696e6563726166744d6f74645061727365723f7374796c653d666f722d7468652d6261646765)[![](https://camo.githubusercontent.com/86a5dde4c72c3cad23093796611910ccdf4d1b2892198fe0d833232a06c9b8a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465762d6c616e6365722f6d696e6563726166742d6d6f74642d7061727365723f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/86a5dde4c72c3cad23093796611910ccdf4d1b2892198fe0d833232a06c9b8a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465762d6c616e6365722f6d696e6563726166742d6d6f74642d7061727365723f7374796c653d666f722d7468652d6261646765)

PHP library to parse minecraft server motd

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

[](#installation)

This library can be installed by issuing the following command:

```
composer require dev-lancer/minecraft-motd-parser
```

Documentation
-------------

[](#documentation)

Lang[EN](docs/en/home.md)[PL](docs/pl/home.md)Parsing
-------

[](#parsing)

### Usage TextParser

[](#usage-textparser)

To parse a text-based MOTD using custom formatting and colors:

```
$formatCollection = \DevLancer\MinecraftMotdParser\Collection\FormatCollection::generate();
$colorCollection  = \DevLancer\MinecraftMotdParser\Collection\ColorCollection::generate(true); //When set to true, colors from BE are added
$parser = new \DevLancer\MinecraftMotdParser\Parser\TextParser($formatCollection, $colorCollection, '&');

$motd = "A &l&fMine&4craft &rServer";
$motdItemCollection = $parser->parse($motd, new \DevLancer\MinecraftMotdParser\Collection\MotdItemCollection());
```

### Usage ArrayParser

[](#usage-arrayparser)

To parse a structured array-based MOTD:

```
$formatCollection = \DevLancer\MinecraftMotdParser\Collection\FormatCollection::generate();
$colorCollection  = \DevLancer\MinecraftMotdParser\Collection\ColorCollection::generate();
$parser = new \DevLancer\MinecraftMotdParser\Parser\ArrayParser($formatCollection, $colorCollection);

$motd = [
    [ "text" => "A "],
    [
        "bold" => true,
        "extra" => [
            [
                "color" => "white",
                "text" => "Mine"
            ],
            [
                "color" => "dark_red",
                "text" => "craft "
            ],
        ]
    ],
    [
        "text" => "Server"
    ]
];
$motdItemCollection = $parser->parse($motd, new \DevLancer\MinecraftMotdParser\Collection\MotdItemCollection());
```

### Merging Similar Items

[](#merging-similar-items)

The mergeSimilarItem() method in the MotdItemCollection class merges adjacent MotdItem objects with the same formatting and color. This optimization helps to reduce redundancy in the formatting and color codes, making the MOTD more concise.

```
$motd = "A &l&fMine&f&lcraft &rServer";
$motdItemCollection = $parser->parse($motd, new \DevLancer\MinecraftMotdParser\Collection\MotdItemCollection());

//Output before
[
    ['text': "A "],
    ['bold': true, 'color': "white", 'text': "Mine"],
    ['bold': true, 'color': "white", 'text': "craft "],
    ['reset': true, 'text': "Server"],
]

$motdItemCollection->mergeSimilarItem();
//Output after
[
    ['text': "A "],
    ['bold': true, 'color': "white", 'text': "Minecraft "],
    ['reset': true, 'text': "Server"],
]
```

Generation
----------

[](#generation)

### MotdItemCollection

[](#motditemcollection)

Example of creating a MotdItemCollection:

```
$parser = new \DevLancer\MinecraftMotdParser\Parser\TextParser();
$motd = "A §l§fMine§4craft §rServer";
$motdItemCollection = $parser->parse($motd, new \DevLancer\MinecraftMotdParser\Collection\MotdItemCollection());
```

### Usage HtmlGenerator

[](#usage-htmlgenerator)

To generate HTML from a parsed MOTD:

```
$generator = new \DevLancer\MinecraftMotdParser\Generator\HtmlGenerator();

// Generate HTML from the MOTD item collection
echo $generator->generate($motdItemCollection);
```

#### Output

[](#output)

The output will be:

```
A Mine
craft  Server
```

### Usage RawGenerator

[](#usage-rawgenerator)

To generate raw text from a parsed MOTD:

```
$generator = new \DevLancer\MinecraftMotdParser\Generator\RawGenerator("§");
// Generate raw text from the MOTD item collection
echo $generator->generate($motdItemCollection);
//output: A §f§lMine§4craft §rServer
```

### Usage TextGenerator

[](#usage-textgenerator)

To generate plain text from a parsed MOTD:

```
$generator = new \DevLancer\MinecraftMotdParser\Generator\TextGenerator();
// Generate plain text from the MOTD item collection
echo $generator->generate($motdItemCollection);
//output: A Minecraft Server
```

Custom formatter
----------------

[](#custom-formatter)

### Define new class formatter

[](#define-new-class-formatter)

Example of creating a custom bold formatter:

```
class CustomBoldFormatter implements FormatterInterface
{
    public function getKey(): string
    {
        return 'l';
    }

    public function getName(): string
    {
        return 'bold';
    }

    public function getFormat(): string
    {
        return '%s';
    }
}
```

### Usage

[](#usage)

To use the custom formatter:

```
// Create a new format collection
$formatCollection = \DevLancer\MinecraftMotdParser\Collection\FormatCollection::generate();

// and override the default formatter for bold
$formatCollection->add(new CustomBoldFormatter());

// Create a new MOTD item
$motdItem = new \DevLancer\MinecraftMotdParser\MotdItem();
$motdItem->setBold(true);
$motdItem->setText("Hello World");

// Create a new MOTD item collection and add the MOTD item
$motdItemCollection = new \DevLancer\MinecraftMotdParser\Collection\MotdItemCollection();
$motdItemCollection->add($motdItem);

// Generate HTML using the custom formatter
$generator = new \DevLancer\MinecraftMotdParser\Generator\HtmlGenerator($formatCollection);
echo $generator->generate($motdItemCollection);
```

### Output

[](#output-1)

The output will be:

```
Hello World
```

License
-------

[](#license)

This library is licensed under the [MIT](LICENSE) License.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance41

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.8% 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 ~20 days

Recently: every ~27 days

Total

11

Last Release

582d ago

Major Versions

v0.2 → v1.02024-06-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c5ff1caa1095245f5cd5bc03e93f74db10210c2283e2f15dfcb3e8cbd654391?d=identicon)[bubanga](/maintainers/bubanga)

---

Top Contributors

[![jgniecki](https://avatars.githubusercontent.com/u/19625445?v=4)](https://github.com/jgniecki "jgniecki (90 commits)")[![Krymonota](https://avatars.githubusercontent.com/u/12609161?v=4)](https://github.com/Krymonota "Krymonota (3 commits)")

---

Tags

generatormineceraftmotdparserphpphpparsergeneratorserverminecraftmotd

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dev-lancer-minecraft-motd-parser/health.svg)

```
[![Health](https://phpackages.com/badges/dev-lancer-minecraft-motd-parser/health.svg)](https://phpackages.com/packages/dev-lancer-minecraft-motd-parser)
```

###  Alternatives

[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22476.7M6](/packages/felixfbecker-language-server-protocol)[wsdltophp/packagegenerator

Generate hierarchical PHP classes based on a WSDL

4351.9M19](/packages/wsdltophp-packagegenerator)[php-mcp/server

PHP SDK for building Model Context Protocol (MCP) servers - Create MCP tools, resources, and prompts

828280.5k25](/packages/php-mcp-server)[renoki-co/laravel-healthchecks

Laravel Healthchecks is a simple controller class that helps you build your own healthchecks endpoint without issues.

5654.9k](/packages/renoki-co-laravel-healthchecks)[appserver-io/webserver

Multithreaded webserver for php written in php

455.7k1](/packages/appserver-io-webserver)[mmoreram/translation-server

PHP translation server

233.7k2](/packages/mmoreram-translation-server)

PHPackages © 2026

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