PHPackages                             seatlon/cs2-log - 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. seatlon/cs2-log

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

seatlon/cs2-log
===============

Counter-Strike 2 log parsing in PHP

v2.0.7(3mo ago)1424MITPHPPHP ^8.1CI passing

Since Jan 9Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/SeatloN/cs2-log)[ Packagist](https://packagist.org/packages/seatlon/cs2-log)[ Docs](https://github.com/seatlon/cs2-log)[ RSS](/packages/seatlon-cs2-log/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (23)Used By (0)

Counter-Strike log parsing in PHP
=================================

[](#counter-strike-log-parsing-in-php)

Parsing Counter-Strike (2) logs in PHP. Provides typed objects for each log and a class for matching individual log lines.

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

[](#installation)

You can install the package via composer:

```
composer require seatlon/cs2-log
```

Usage Examples
--------------

[](#usage-examples)

### Basic Usage (Line by Line - Backwards Compatible)

[](#basic-usage-line-by-line---backwards-compatible)

```
use CSLog\CS2\Patterns;

$lines = file('server.log', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

foreach ($lines as $line) {
    $event = Patterns::match($line);

    if ($event) {
        // Process event
    }
}
```

### Advanced Usage (Full Parser with Carbon)

[](#advanced-usage-full-parser-with-carbon)

```
use CSLog\CS2\Parser;
use CSLog\CS2\Models\RoundStats;
use CSLog\CS2\Models\TeamPlaying;
use CSLog\CS2\Models\ServerCVar;
use CSLog\CS2\Models\Kill;

$logContent = file_get_contents('server.log');
$parser = new Parser();
$events = $parser->parse($logContent);

foreach ($events as $event) {
    if ($event instanceof RoundStats) {
        echo "Round {$event->roundNumber} at {$event->timestamp->format('H:i:s')}\n";
        echo "Score: CT {$event->scoreCT} - {$event->scoreT} T\n";

        foreach ($event->players as $playerKey => $stats) {
            if ($stats['accountid'] > 0) {
                echo "  {$stats['accountid']}: {$stats['kills']}K / {$stats['deaths']}D\n";
            }
        }
    } elseif ($event instanceof TeamPlaying) {
        echo "Team {$event->side}: {$event->teamName}\n";
        echo "Assigned at: {$event->timestamp->format('H:i:s')}\n";
    } elseif ($event instanceof ServerCVar) {
        echo "Server setting: {$event->cvar} = {$event->value}\n";
    } elseif ($event instanceof Kill) {
        echo "{$event->attacker->name} killed {$event->victim->name}\n";
        echo "Time: {$event->timestamp->diffForHumans()}\n";
    }
}
```

### Working with Carbon Timestamps

[](#working-with-carbon-timestamps)

```
use Carbon\Carbon;

// Filter events by time
$recentEvents = array_filter($events, function($event) {
    return $event->timestamp->isAfter(Carbon::now()->subHour());
});

// Get events from specific date
$dateEvents = array_filter($events, function($event) {
    return $event->timestamp->isSameDay('2026-01-19');
});

// Group events by hour
$hourlyGroups = collect($events)->groupBy(function($event) {
    return $event->timestamp->format('Y-m-d H:00');
});

// Calculate time differences
$firstEvent = $events[0];
$lastEvent = end($events);
$duration = $firstEvent->timestamp->diffInMinutes($lastEvent->timestamp);
echo "Match duration: {$duration} minutes\n";
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Credits
-------

[](#credits)

- [Alexander Nilsson (SeatloN)](https://github.com/SeatloN)
- [Harry (hjbdev)](https://github.com/hjbdev)
- [All Contributors](../../contributors)
- [eBot](https://github.com/deStrO/eBot-CSGO) (for some of the original Global Offensive patterns, which I have updated and refined for CS2)

License
-------

[](#license)

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

Docker Build Command
--------------------

[](#docker-build-command)

```
docker build -t cs2-log .
```

Docker Run Command
------------------

[](#docker-run-command)

```
docker run --rm --tty cs2-log
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance80

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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 ~37 days

Recently: every ~1 days

Total

21

Last Release

107d ago

Major Versions

v1.1.2 → v2.02026-01-23

### Community

Maintainers

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

---

Top Contributors

[![SeatloN](https://avatars.githubusercontent.com/u/22331806?v=4)](https://github.com/SeatloN "SeatloN (58 commits)")

---

Tags

seatloncs2-log

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/seatlon-cs2-log/health.svg)

```
[![Health](https://phpackages.com/badges/seatlon-cs2-log/health.svg)](https://phpackages.com/packages/seatlon-cs2-log)
```

###  Alternatives

[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k14.6M107](/packages/spatie-laravel-sitemap)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9738.8k](/packages/sauladam-shipment-tracker)[professional-wiki/edtf

PHP library to parse, represent and work with dates that follow the Extended Date/Time Format specification.

10432.1k4](/packages/professional-wiki-edtf)

PHPackages © 2026

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