PHPackages                             aon4o/cs2-gsi-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. aon4o/cs2-gsi-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

aon4o/cs2-gsi-parser
====================

A parser for CS2 Game State Integration data.

v0.4.0(5mo ago)154[1 PRs](https://github.com/aon4o/cs2-gsi-parser/pulls)MITPHPPHP ^8.4CI passing

Since Oct 10Pushed 2mo agoCompare

[ Source](https://github.com/aon4o/cs2-gsi-parser)[ Packagist](https://packagist.org/packages/aon4o/cs2-gsi-parser)[ Docs](https://github.com/aon4o/cs2-gsi-parser)[ GitHub Sponsors](https://github.com/aon4o)[ RSS](/packages/aon4o-cs2-gsi-parser/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

A parser for CS2 Game State Integration data.
=============================================

[](#a-parser-for-cs2-game-state-integration-data)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7b25b36643abb34970408128c90e423ca957138e9947d7f2783c96dcd29dbb28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616f6e346f2f6373322d6773692d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aon4o/cs2-gsi-parser)[![Tests](https://camo.githubusercontent.com/2ec28501840810561c27a95430ce43398fe36b79a46178e6d83f120df7575738/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616f6e346f2f6373322d6773692d7061727365722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/aon4o/cs2-gsi-parser/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/d97dad76bc24f0c7c682cde69f54f76de0407ead5232c8dfe7bf62a71f348cb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616f6e346f2f6373322d6773692d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aon4o/cs2-gsi-parser)

This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/13fff96d18761aa3ecc7a9e53157f2aab53e260997c2ce618667997e89da5709/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6373325f6773695f7061727365722e6a70673f743d31)](https://spatie.be/github-ad-click/cs2_gsi_parser)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require aon4o/cs2-gsi-parser
```

Usage
-----

[](#usage)

### Parser

[](#parser)

The GameState::from() function accepts a JSON string, an associative array or an object.

The result you get back is a fully typed object representing the game state.

```
use Aon4o\Cs2GsiParser\GameState;

/** @var string|array|object $data */
$game_state = GameState::from($data);

echo $game_state->map->name; // de_dust2
```

### Config generator

[](#config-generator)

You can also generate a config file for CS2 GSI.

```
use Aon4o\Cs2GsiParser\ConfigWriter;

$config = ConfigWriter::new()
    ->setUrl('http://yourdomain.com/cs2-gsi-endpoint')
    ->setAuthToken('your_auth_key')
    ->setSettings(timeout: 5.0, buffer: 0.1, throttle: 0.1, heartbeat: 30.0)
    ->get();

echo $config;
// "cs2-gsi"
// {
//     "uri" "http://yourdomain.com/cs2-gsi-endpoint"
//     "timeout" "5"
//     "buffer"  "0.1"
//     "throttle" "0.1"
//     "heartbeat" "30"
//     "auth"
//     {
//         "token" "your_auth_key"
//     }
//     "data"
//     {
//         "map_round_wins" "1"
//         "map" "1"
//         "player_id" "1"
//         "player_match_stats" "1"
//         "player_state" "1"
//         "player_weapons" "1"
//         "provider" "1"
//         "round" "1"
//         "allgrenades" "1"
//         "allplayers_id" "1"
//         "allplayers_match_stats" "1"
//         "allplayers_position" "1"
//         "allplayers_state" "1"
//         "allplayers_weapons" "1"
//         "bomb" "1"
//         "phase_countdowns" "1"
//         "player_position" "1"
//     }
// }
```

### Event Extractor

[](#event-extractor)

The package also provides a custom event extractor. This is not a feature of CS2 GSI, but a custom definition of events based on changes in the game state. The events are defined in the `Aon4o\Cs2GsiParser\Enums\Custom\Event` enum.

```
use Aon4o\Cs2GsiParser\GameState;
use Aon4o\Cs2GsiParser\EventExtractor;

/** @var GameState $prev */
/** @var GameState $curr */

new EventExtractor($prev, $curr)->allEvents();
new EventExtractor($prev, $curr)->mapEvents();
new EventExtractor($prev, $curr)->playerEvents();
new EventExtractor($prev, $curr)->roundEvents();

// Example output

 array:1 [
    0 => Aon4o\Cs2GsiParser\Enums\Custom\Event {#741
      +name: "MAP_PHASE_CHANGED"
      +value: "map.phase_changed"
    }
  ]
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Alex Naida](https://github.com/aon4o)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 87% of packages

Maintenance80

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~0 days

Total

4

Last Release

161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/927acab553d76e07d6d2e2081b7eb6bea657b9550901a036f647b6a7f5af5c66?d=identicon)[aon4o](/maintainers/aon4o)

---

Top Contributors

[![aon4o](https://avatars.githubusercontent.com/u/48474870?v=4)](https://github.com/aon4o "aon4o (6 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

cs2gsiparserparsercsgocs2aon4ogsics2-gsi-parser

###  Code Quality

TestsPest

Static AnalysisRector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/aon4o-cs2-gsi-parser/health.svg)

```
[![Health](https://phpackages.com/badges/aon4o-cs2-gsi-parser/health.svg)](https://phpackages.com/packages/aon4o-cs2-gsi-parser)
```

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k887.0M1.6k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k896.2M97](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.0k150.2M630](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

2.9k393.7M556](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k234.7M187](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k185.5M57](/packages/sabberworm-php-css-parser)

PHPackages © 2026

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