PHPackages                             risendy/pgn-parser-bundle - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. risendy/pgn-parser-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

risendy/pgn-parser-bundle
=========================

Symfony Pgn Parser Bundle

v1.0.2(5y ago)015PHPPHP ^7.2.5

Since Jan 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/risendy/pgnParserBundle)[ Packagist](https://packagist.org/packages/risendy/pgn-parser-bundle)[ RSS](/packages/risendy-pgn-parser-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (4)Used By (0)

Table of contents
-----------------

[](#table-of-contents)

- [General info](#general-info)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Tests](#tests)

General info
------------

[](#general-info)

Simple symfony bundle for parsing pgn chess notations. PGN should be in string format, default tags delimiter is newline. There should be at least one blank line between tags and moves because it is used to process the pgn string.

Features
--------

[](#features)

- extracting moves in string/json/array/object array formats
- getting specific moves (black or white)
- getting specific move comment
- getting first/last move
- extracting tags in string format
- getting tags value by name

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

[](#installation)

```
composer require risendy/pgn-parser-bundle

```

Usage
-----

[](#usage)

To parse pgn string:

```
$game = new ChessParser();
$game->parsePgn($pgn);

```

To get moves in string format:

```
$moves = $game->getMovesString();

result:
string(15) "e4 e6 d4 d5 0-1"

```

To get moves in json format:

```
$json = $game->createJsonArray();

result:
{
   "tags":{
      "Event":"Lets Play!",
      "Site":"Chess.com",
      "Date":"2018.12.04",
      "Round":"?",
      "White":"guilherme_1910",
      "Black":"bmbio",
      "Result":"0-1",
      "TimeControl":"1\/259200:0"
   },
   "moves":[
      {
         "moveNumber":1,
         "white":"e4",
         "black":"e6"
      },
      {
         "moveNumber":2,
         "white":"d4",
         "black":null
      }
   ]
}

```

To get moves in array format:

```
$moves = $game->getSimpleMovesArray();

result:
array(5) {
  [0]=>
  string(2) "e4"
  [1]=>
  string(2) "e6"
  [2]=>
  string(2) "d4"
  [3]=>
  string(2) "d5"
  [4]=>
  string(3) "0-1"
}

```

To get moves in object array format:

```
$moves = $game->getObjectMovesArray();

result:
array(3) {
  [1]=>
  array(2) {
    [0]=>
    object(PgnParser\Move)#22 (3) {
      ["move":"PgnParser\Move":private]=>
      string(2) "e4"
      ["moveNumber":"PgnParser\Move":private]=>
      int(1)
      ["moveColor":"PgnParser\Move":private]=>
      string(1) "W"
    }
    [1]=>
    object(PgnParser\Move)#23 (3) {
      ["move":"PgnParser\Move":private]=>
      string(2) "e6"
      ["moveNumber":"PgnParser\Move":private]=>
      int(1)
      ["moveColor":"PgnParser\Move":private]=>
      string(1) "B"
    }
  }
  [2]=>
  array(2) {
    [0]=>
    object(PgnParser\Move)#24 (3) {
      ["move":"PgnParser\Move":private]=>
      string(2) "d4"
      ["moveNumber":"PgnParser\Move":private]=>
      int(2)
      ["moveColor":"PgnParser\Move":private]=>
      string(1) "W"
    }
    [1]=>
    object(PgnParser\Move)#25 (3) {
      ["move":"PgnParser\Move":private]=>
      string(2) "d5"
      ["moveNumber":"PgnParser\Move":private]=>
      int(2)
      ["moveColor":"PgnParser\Move":private]=>
      string(1) "B"
    }
  }
  [3]=>
  array(1) {
    [0]=>
    object(PgnParser\Move)#26 (3) {
      ["move":"PgnParser\Move":private]=>
      string(3) "0-1"
      ["moveNumber":"PgnParser\Move":private]=>
      int(3)
      ["moveColor":"PgnParser\Move":private]=>
      string(1) "W"
    }
  }
}

```

To get specific move instance:

```
$move = $game->getMove(2, 'B');

result:
object(PgnParser\Move)#75 (4) {
["san":"PgnParser\Move":private]=>
string(2) "d4"
["moveNumber":"PgnParser\Move":private]=>
int(2)
["moveColor":"PgnParser\Move":private]=>
string(1) "W"
["comment":"PgnParser\Move":private]=>
string(4) "test"

```

To get specific move san:

```
$move = $game->getMove(2, 'B')->getSan();

result:
string(2) "d5"

```

To get specific move comment:

```
$move = $game->getMove(2, 'B')->getComment();

result:
string(4) "test"

```

To get tag value by name:

```
$tagValue = $game->getTagValueByName('Black');

result:
string(5) "bmbio"

```

Tests
-----

[](#tests)

If you want to run tests there are in tests catalog.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Total

3

Last Release

1977d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5420748?v=4)[Kuba](/maintainers/risendy)[@risendy](https://github.com/risendy)

---

Top Contributors

[![risendy](https://avatars.githubusercontent.com/u/5420748?v=4)](https://github.com/risendy "risendy (8 commits)")

---

Tags

chesschess-pgnchess-pgn-parser

### Embed Badge

![Health badge](/badges/risendy-pgn-parser-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/risendy-pgn-parser-bundle/health.svg)](https://phpackages.com/packages/risendy-pgn-parser-bundle)
```

###  Alternatives

[phpstubs/phpstubs

Contains PHP Stubs which can be used by IDEs, or static analysis tools

5816.8k](/packages/phpstubs-phpstubs)[inviqa/magento-symfony-container

Provides Magento with an instance of a Symfony DI Container

2436.5k](/packages/inviqa-magento-symfony-container)

PHPackages © 2026

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