Download the PHP package cmuset/chess-tools without Composer
On this page you can find all versions of the php package cmuset/chess-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package chess-tools
ChessTools
A PHP library for parsing and exporting chess notations: PGN, SAN, and FEN.
Table of Contents
- Installation
- Quick Start
- Tools
- Model Layer
- Enums Reference
- Testing & Development
Installation
Requires PHP >= 8.4.
Quick Start
Tools
Parsers — docs/tools/parser.md
Convert strings into model objects.
| Class | Input | Output |
|---|---|---|
PGNParser |
PGN string | Game or Game[] |
SANParser |
SAN string + color | Move |
FENParser |
FEN string | Position |
Exporters — docs/tools/exporter.md
Serialize model objects back to strings.
| Class | Input | Output |
|---|---|---|
GameExporter |
Game or Variation |
PGN string |
MoveExporter |
Move |
SAN string |
PositionExporter |
Position |
FEN string |
MoveApplier — docs/tools/move-applier.md
Applies a Move to a Position, enforcing all chess rules: castling rights, en passant, promotion, counters, and post-move check validation.
Validators — docs/tools/validator.md
Check positions and games for illegal states.
| Class | Validates |
|---|---|
PositionValidator |
A single Position (kings, check, pawns, en passant) |
GameValidator |
A full Game — replays every move including sub-variations |
Resolvers — docs/tools/resolver.md
Derive information absent from raw SAN: source squares, capture flags, and check/checkmate markers.
| Class | Resolves |
|---|---|
MoveResolver |
A single Move against a Position |
VariationResolver |
All moves in a Variation sequentially |
GameResolver |
The full game main line + result detection |
VariationSplitter — docs/tools/splitter.md
Extracts all nested variations into a flat list of independent Variation objects, each prefixed with the moves preceding the divergence.
VariationMerger — docs/tools/merger.md
Merges Variation objects back into a main line, inserting diverging moves as nested sub-variations at the correct branching points.
Model Overview
| Class | Description | Docs |
|---|---|---|
Game |
Full PGN game: tags, initial position, main line, result | → |
Position |
Board state: pieces, side to move, castling rights, en passant, counters | → |
Variation |
Ordered collection of MoveNode instances, keyed by "1." / "1..." notation |
→ |
MoveNode |
Node in the move tree: move + move number + comments + NAGs + sub-variations | → |
Move |
Parsed SAN move: piece, destination, flags (capture, check, castling, promotion) | → |
Square |
A board square: coordinates + optional piece | → |
Enums Reference
All domain concepts are PHP string-backed enums.
| Enum | Values | Docs |
|---|---|---|
ColorEnum |
WHITE 'w' · BLACK 'b' |
→ |
PieceEnum |
WHITE_KING 'K' … BLACK_PAWN 'p' (12 cases) |
→ |
CoordinatesEnum |
A1 'a1' … H8 'h8' (64 cases) |
→ |
CastlingEnum |
WHITE_KINGSIDE 'K' · WHITE_QUEENSIDE 'Q' · BLACK_KINGSIDE 'k' · BLACK_QUEENSIDE 'q' |
→ |
ResultEnum |
WHITE_WINS '1-0' · BLACK_WINS '0-1' · DRAW '1/2-1/2' · ONGOING '*' |
→ |
Testing & Development
Or with Docker:
MIT License. See LICENSE.