{"id":18468170,"url":"https://github.com/p-chess/chess","last_synced_at":"2026-01-02T13:23:41.910Z","repository":{"id":38411916,"uuid":"254135617","full_name":"p-chess/chess","owner":"p-chess","description":"PHP Chess engine","archived":false,"fork":false,"pushed_at":"2025-06-30T12:21:44.000Z","size":189,"stargazers_count":45,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-10T23:37:11.552Z","etag":null,"topics":["chess","chess-engine","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p-chess.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-08T16:02:58.000Z","updated_at":"2025-10-01T15:16:21.000Z","dependencies_parsed_at":"2024-09-15T19:44:40.367Z","dependency_job_id":"13ed3eb9-437e-42f0-b7f9-cb8a703c0b1f","html_url":"https://github.com/p-chess/chess","commit_stats":{"total_commits":52,"total_committers":5,"mean_commits":10.4,"dds":0.1923076923076923,"last_synced_commit":"d20b11af83ae11bbbbcfbcc3d5ea4cedc3e2f44e"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/p-chess/chess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-chess%2Fchess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-chess%2Fchess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-chess%2Fchess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-chess%2Fchess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-chess","download_url":"https://codeload.github.com/p-chess/chess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-chess%2Fchess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28172827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-02T02:00:06.235Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","chess-engine","php"],"created_at":"2024-11-06T10:05:13.311Z","updated_at":"2026-01-02T13:23:41.905Z","avatar_url":"https://github.com/p-chess.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chess\n\nChess is a PHP chess library used for chess move\ngeneration/validation, piece placement/movement, and check/checkmate/stalemate\ndetection - basically everything but the AI. \n\nNOTE: this started as a port of [chess.js](https://github.com/jhlywa/chess.js) for PHP, forked from [ryanhs/chess.php](https://github.com/ryanhs/chess.php)\n\n[![Latest Stable Version](https://poser.pugx.org/p-chess/chess/v/stable)](https://packagist.org/p-chess/chess)\n[![MIT License](https://poser.pugx.org/p-chess/chess/license)](https://packagist.org/packages/p-chess/chess)  \n\n## Installation\n\nuse composer with `composer require p-chess/chess`\nor put in your composer.json  \n```\n\"require\": {\n    \"p-chess/chess\": \"^1.0\"\n}\n```\n\n## Example Code\nThe code below plays a complete game of chess ... randomly.\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\nuse \\PChess\\Chess\\Chess;\nuse \\PChess\\Chess\\Output\\UnicodeOutput;\n\n$chess = new Chess();\nwhile (!$chess-\u003egameOver()) {\n    $moves = $chess-\u003emoves();\n    $move = $moves[random_int(0, count($moves) - 1)];\n    $chess-\u003emove($move-\u003esan);\n}\n\necho (new UnicodeOutput())-\u003erender($chess) . PHP_EOL;\n```\n\n```\n   +---+---+---+---+---+---+---+---+\n 8 |   | ♜ | ♘ |   |   |   |   |   | \n   +---+---+---+---+---+---+---+---+\n 7 | ♞ |   |   |   |   |   |   |   | \n   +---+---+---+---+---+---+---+---+\n 6 |   |   |   |   |   |   |   |   | \n   +---+---+---+---+---+---+---+---+\n 5 |   |   |   |   |   |   |   |   | \n   +---+---+---+---+---+---+---+---+\n 4 |   |   |   |   |   | ♚ | ♟ |   | \n   +---+---+---+---+---+---+---+---+\n 3 | ♜ |   |   |   |   |   |   |   | \n   +---+---+---+---+---+---+---+---+\n 2 |   |   |   |   |   |   |   |   | \n   +---+---+---+---+---+---+---+---+\n 1 | ♔ |   |   |   | ♞ |   |   |   | \n   +---+---+---+---+---+---+---+---+\n     a   b   c   d   e   f   g   h\n```\n\n## Supported output formats\n\n### ASCII\n\nPieces are displayed with corresponding codes (e.g. \"p\" for pawn, \"q\" for queen, etc.).\n\n```php\n\u003c?php\n// use...\n$chess = new Chess();\necho (new AsciiOutput())-\u003erender($chess);\n```\n\n### Unicode\n\nPieces are displayed like in the example above.\n\n```php\n\u003c?php\n// use...\n$chess = new Chess();\necho (new UnicodeOutput())-\u003erender($chess);\n```\n\n### PNG Image\n\nPieces are displayed inside a png image.\n\n```php\n\u003c?php\n// use...\n$chess = new Chess();\n$imagine = new \\Imagine\\Gd\\Imagine();   // or \\Imagine\\Imagick\\Imagine()\n$output = new ImageOutput($imagine, '/your/path/to/images', 480);\nheader('Content-Type: image/png');  \necho $output-\u003erender($chess);\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/179866/112304837-411be280-8c9e-11eb-8333-c2489f9bef05.png\"\u003e        \n\nSee [dedicated documentation](docs/output_imagine.md) for detailed instructions.\n\n### SVG Image\n\nPieces are displayed inside an SVG image.\n\n```php\n\u003c?php\n// use...\n$chess = new Chess();\n$output = new SvgOutput();\necho $output-\u003erender($chess);\n```\n\n\u003cimg src=\"https://private-user-images.githubusercontent.com/179866/457647250-34bae1e1-83c5-47b1-a997-0b5bf4041d2a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTEyODYyNTgsIm5iZiI6MTc1MTI4NTk1OCwicGF0aCI6Ii8xNzk4NjYvNDU3NjQ3MjUwLTM0YmFlMWUxLTgzYzUtNDdiMS1hOTk3LTBiNWJmNDA0MWQyYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwNjMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDYzMFQxMjE5MThaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wYzFlOTFiNjcxZjYzMDViZGIyNmNkOGRmZmJmZmM2ZWRjZmI3YzMxODFiNWI5ZGFjZjQ1ZTM1ZGQzMjU4OTdkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Rqfjlhx-qVfMpo09u0s9Lf4Wk3X9OnkZ1n0VsNOznX0\"\u003e\n\n### HTML\n\nPieces are displayed inside an HTML table.\n\nSee [dedicated documentation](docs/output_html.md) for detailed instructions.\n\n## Performance\n\nThere is still a lot to do in this topic.  \n[akondas/php-grandmaster](https://github.com/akondas/php-grandmaster) is a good place to start experiment ;)\n\n### Chess::move()\n\n| iteration |   mean    | comment                                                                        |\n|:---------:|:---------:|--------------------------------------------------------------------------------|\n|     1     | 548.819μs | initial                                                                        |\n|     2     | 447.973μs | replace fen with json_encode in history position (inThreefoldRepetition cache) |\n|     3     | 340.375μs | replace fen with json_encode in generateMoves                                  |\n|     4     | 333.145μs | add boardHash calculation on make/undo move                                    |\n|     5     | 25.917μs  | :fire: add cache for moveToSAN method                                          |\n\n## Other documentation\n\nAll classes are documented in the [docs directory](docs/index.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-chess%2Fchess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-chess%2Fchess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-chess%2Fchess/lists"}