Skip to content
A PHP 5.5+ library that parses StarCraft II replay files into a rich object oriented graph.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
s2protocol @ a28c7e2

Star Replay

This library allows you to read StarCraft II replay files from PHP.

A object-oriented API is provided to browse through all metadata and events available on replays.


  • Read .SC2Replay files from all public game versions (data is mined from s2protocol)
  • Game events: Streams events using PHP 5 generators
  • Lazy parsing: Parses only structures you require


The recommended way of installing this library is using Composer.

composer require "rogiel/star-replay"

This library uses php-mpq to parse and extract compressed information inside replays.


use Rogiel\StarReplay\Replay;
use Rogiel\StarReplay\Event\Game\CameraSaveEvent;

$replay = new Replay('test.SC2Replay');

echo "Version: " . $replay->getHeader()->getVersion() . "\n";
echo "Map: " . $replay->getMatchInformation()->getTitle() . "\n";
echo "Players:\n";
foreach($replay->getPlayers() as $id => $player) {
	echo "\tPlayer ".$id.": ".$player->getName()."\n";

echo "Camera hotkeys:\n";
foreach($replay->getGameEvents() as $timestamp => $event) {
	if($event instanceof CameraSaveEvent) {
		$player = $replay->getPlayers()->getPlayer($event->getHeader()->getUserID());
		echo "\tPlayer ". $player->getName() ." saved a new camera #". $event->getWhich() ." at point ". $event->getTarget() ."\n";
	// since we are using generators, the events will stream linearly from begining to end
You can’t perform that action at this time.