PHPackages                             beheh/sulphur - 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. beheh/sulphur

ActiveLibrary

beheh/sulphur
=============

Parse and filter game references from Clonk masterservers

3.0.0(9y ago)3531[2 issues](https://github.com/beheh/sulphur/issues)ISCPHPPHP &gt;=5.3.0

Since Jun 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/beheh/sulphur)[ Packagist](https://packagist.org/packages/beheh/sulphur)[ RSS](/packages/beheh-sulphur/feed)WikiDiscussions master Synced today

READMEChangelog (8)DependenciesVersions (11)Used By (0)

Sulphur
=======

[](#sulphur)

[![Packagist](https://camo.githubusercontent.com/9626973e1fbe73587b9ceb3d4b7f642a0f12e03cdca9095db0cb3c86b2986d21/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62656865682f73756c706875722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beheh/sulphur)[![License](https://camo.githubusercontent.com/83709589e7cbe72c7502180f0172e4cd33408c09b12146987a1a9d018ba965b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62656865682f73756c706875722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beheh/sulphur)[![Travis](https://camo.githubusercontent.com/5af038a8bee9f728fa4e99e2243eadfbbf603f66f2a40aa575f782787cb882ba/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f62656865682f73756c706875722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/beheh/sulphur)

A full library to parse and filter data from the Clonk masterserver protocol, as used in the games Clonk Rage () and OpenClonk ().

This library was created by Benedict Etzel () and is licensed under the ISC license.

Installing
----------

[](#installing)

Install Sulphur by using [composer](https://getcomposer.org/).

```
$ composer require beheh/sulphur
```

Examples
--------

[](#examples)

```
// fetch masterserver response
$parser = new BehEh\Sulphur\Parser();
$response = $parser->parse(file_get_contents('example.com:80'));

// count all running games
echo count($response->where('State')->is('Running')).' game(s) are currently running';

// iterate through all games currently in lobby
foreach($response->where('State')->is('Lobby') as $reference) {
    echo $reference->Title.' is now open!';
}

// show comment of first game containing "CMC" (case insensitive)
$references = $response->where('Title')->contains('cmc', true);
echo $references[0]->Comment;

// show title of first running league game
$references = $response->where('State')->is('Running')
                       ->where('League')->doesNotExist();
echo $references[0]->Title;

// count games for Clonk Rage or OpenClonk
$references = $response->where('Game')->passes(function($field, $value) { return $value === 'Clonk Rage' || $value === 'OpenClonk'; });
echo count($references).' Clonk Rage and OpenClonk games open';

// print all player names in a reference
foreach($reference->first('PlayerInfos')->all('Client') as $client) {
	foreach($client->all('Player') as $player) {
		echo $player->Name;
	}
}
```

Basic usage
-----------

[](#basic-usage)

You can access the master data by using the parser and passing masterserver data.

```
use BehEh\Sulphur\Parser;

$parser = new Parser();
$response = $parser->parse($data);
```

It's recommended to cache this data so the masterserver doesn't blacklist your server.

Game references
---------------

[](#game-references)

Game sessions are tracked as game references. They can have a variety of fields which describe something about the game.

### Access

[](#access)

To access references, simply call the corresponding functions in the reference object:

```
$references = $response->all();
$references = $response->where('Title')->is('Clepal');
$reference = $response->first('Reference'); // or $response->first()
```

The calls return an object which should handle like an array.

### Filtering

[](#filtering)

Responses can be filtered in multiple ways:

```
$response->where('State')->is('Lobby');
$response->where('League')->exists();
$response->where('Comment')->contains('friendly');
$response->where('Comment')->contains('friendly', true); // case insensitive
$response->where('Version')->matches('/4(,[0-9]+){3}/');
```

Inverse filtering is also available:

```
$response->where('State')->isNot('Running');
$response->where('League')->doesNotExist();
$response->where('Comment')->doesNotContain('bad');
$response->where('Comment')->doesNotContains('bad', true); // case insensitive
$response->where('Version')->doesNotMatch('/5(,[0-9]+){3}/');
```

You can also use custom callbacks (anything accepted by call\_user\_func):

```
$response->where('Title')->passes(function($field, $value) { return strlen($value) > 5; });
$response->where('Title')->doesNotPass(function($field, $value) { return strlen($value) where('State')->is('Running')->where('League')->exists();
$response->where('State')->is('Lobby')->where('Password')->doesNotExist();
```

### Fields

[](#fields)

Fields are key-value pairs and can be read simply by accessing the corresponding (case-sensitive) local variables:

```
echo $reference->Title;
echo $reference->Game;
```

#### Subsections

[](#subsections)

To access fields in a specific section you can use the `all` and `first` methods:

```
echo $reference->first('PlayerInfos')->first('Client')->first('Player')->Name;
foreach($reference->all('Resource') as $resource) {
	echo $resource->Filename;
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~108 days

Recently: every ~168 days

Total

9

Last Release

3494d ago

Major Versions

v0.1.5 → v1.0.02014-11-18

v1.1.2 → v2.0.02015-01-21

v2.0.1 → 3.0.02016-10-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/687eab5210e73ecfdc6d37d3732eeb4f96fddbfa7698e3bce49f05fabf4c953c?d=identicon)[BehEh](/maintainers/BehEh)

---

Top Contributors

[![beheh](https://avatars.githubusercontent.com/u/929769?v=4)](https://github.com/beheh "beheh (64 commits)")

---

Tags

clonkmasterserverclonkopenclonkmasterserver

### Embed Badge

![Health badge](/badges/beheh-sulphur/health.svg)

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

PHPackages © 2026

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