PHPackages                             ryanhs/chess.php - 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. ryanhs/chess.php

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

ryanhs/chess.php
================

chess.php is a PHP chess library that is used for chess move generation/validation, piece placement/movement, and check/checkmate/stalemate detection - basically everything but the AI. NOTE: this is a port of chess.js for php

v1.0.3(8y ago)147.8k17[2 issues](https://github.com/ryanhs/chess.php/issues)[1 PRs](https://github.com/ryanhs/chess.php/pulls)3MITPHP

Since May 20Pushed 1y ago7 watchersCompare

[ Source](https://github.com/ryanhs/chess.php)[ Packagist](https://packagist.org/packages/ryanhs/chess.php)[ RSS](/packages/ryanhs-chessphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (3)

Chess.php
=========

[](#chessphp)

`chess.php` is a PHP chess library that is used for chess move generation/validation, piece placement/movement, and check/checkmate/stalemate detection - basically everything but the AI.

**NOTE: this is a port of [chess.js](https://github.com/jhlywa/chess.js) for php**

You can check out the original `chess.js` code [here](https://github.com/jhlywa/chess.js).

[![Latest Stable Version](https://camo.githubusercontent.com/034d350903cc9e43f9bb0180ff878fa68cf17bf7f9f691438bb5e46b0eb21b5a/68747470733a2f2f706f7365722e707567782e6f72672f7279616e68732f63686573732e7068702f762f737461626c65)](https://packagist.org/packages/ryanhs/chess.php)[![CI](https://github.com/ryanhs/chess.php/actions/workflows/php.yml/badge.svg)](https://github.com/ryanhs/chess.php/actions/workflows/php.yml)[![MIT License](https://camo.githubusercontent.com/50b7a5d7d163251b40aa13a65fa6e31a05573b4842a575425f0e5ee5a5ecd04b/68747470733a2f2f706f7365722e707567782e6f72672f7279616e68732f63686573732e7068702f6c6963656e7365)](https://packagist.org/packages/ryanhs/chess.php)

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

[](#installation)

You can install this package by running this command assuming you have composer installed.

```
composer require ryanhs/chess.php
```

If you don't have composer installed you can install it directly from their [website](https://getcomposer.org/).

Coding Style
------------

[](#coding-style)

`chess.php` follows PSR-2 coding standards. For example a function name like `do_something()` gets transformed into `doSomething()`. Be sure to correctly indent your code and add comments. Adding comments will help other developers know what a block of code does. Other then that all contributions are welcomed.

Basic Usage
-----------

[](#basic-usage)

Here is a sample code that plays a random game of chess.

```
