huehue / pgn-parser
Parse PGN files
0.7.0
2025-05-16 16:22 UTC
Requires
- php: ^8.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- pestphp/pest: ^3.8
README
A PHP library for parsing Portable Game Notation (PGN) files. This library is designed to extract chess game metadata and moves from PGN strings. It validates move syntax, including support for move annotations.
Features
- PGN Parsing: Parses PGN formatted strings.
- Tag Extraction: Extracts tag pairs (e.g.,
[Event "Chess Game"]
,[Site "Home"]
). - Move Parsing: Parses chess moves, including SAN notation.
- Move Validation: Validates move syntax, including:
- Basic piece moves (e.g., Ne5, Ra1, Qf3)
- Piece captures (e.g., Qxe7, Rxf5)
- Pawn moves (e.g., e4, d5)
- Pawn captures (e.g., exd5, bxa6)
- Pawn promotions (e.g., e8=Q, d8=N+)
- Castling (
O-O
,O-O-O
) - Disambiguation (e.g., Rae1, Nfd2)
- Move annotations/evaluation symbols (+, #, !, ?, !!, ??, !?, ?!)
Installation
The preferred method of installation is via Composer:
composer require huehue/pgn-parser