PHP Chess
A chess library for PHP offering move validation, common formats, multiple variants, UCI engine support, explanation of chess positions, and image recognition.
Installation
Requirements
- PHP >= 8.1
- Stockfish >= 15.1
Composer installation
composer require chesslablab/php-chess
Features
Formats Supported
- Chess moves in LAN and PGN formats.
- Movetext processing in LAN, SAN and RAV formats.
- NAG support for SAN and RAV movetexts.
- UCI protocol.
- FEN conversion to chess board.
- Chess board conversion to PNG and JPG image.
- Chess board conversion to MP4 video.
Acronym | Description |
---|---|
LAN | Long Algebraic Notation |
PGN | Portable Game Notation |
SAN | Standard Algebraic Notation |
RAV | Recursive Annotation Variation |
NAG | Numeric Annotation Glyphs |
UCI | Universal Chess Interface |
FEN | Forsyth-Edwards Notation |
Chess Variants
Multiple variants are supported with the default one being classical chess.
Variant | Chessboard |
---|---|
Capablanca | Chess\Variant\Capablanca\Board |
Capablanca-Fischer | Chess\Variant\CapablancaFischer\Board |
Chess960 | Chess\Variant\Chess960\Board |
Classical | Chess\Variant\Classical\Board |
Dunsany | Chess\Variant\Dunsany\Board |
Losing Chess | Chess\Variant\Losing\Board |
RacingKings | Chess\Variant\RacingKings\Board |
UCI Engines
Listed below are the UCI engines available at the moment.
- Stockfish
Object-Oriented
The chess board representation is an object of type SplObjectStorage as opposed to a bitboard.
Thoroughly Tested
PHP Chess has been developed with a test-driven development (TDD) approach.
The tests/unit folder contains plenty of real examples. Almost every class in the src folder represents a concept that is tested accordingly in the tests/unit folder, in other words, the structure of the tests/unit folder is mirroring the structure of the src folder.
The PHP Chess docs are more of a tutorial rather than an API description. The unit tests are the best documentation. For further details on how to use a particular class, please feel free to browse the codebase and check out the corresponding tests.
Lightweight
PHP dependencies required:
- Rubix ML for machine learning.
- Imagine for image processing.