ryanhs/chess.php

This package is abandoned and no longer maintained. No replacement package was suggested.

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 2017-08-25 08:56 UTC

This package is not auto-updated.

Last update: 2020-03-20 17:26:42 UTC


README

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

Latest Stable Version Build Status MIT License

Installation

use composer with composer require ryanhs/chess.php
or put in your composer.json

"require": {
	"ryanhs/chess.php": "^1.0"
}

if you doesn't know composer, its a really usefull tools in php for package management,
try to learn composer here

Coding Style

about coding style, naming system.. because this is a PHP, i try to stick to use PHP-PSR, like game_over() become gameOver()

just keep in mind, any function name transformed into camelCase

Example Code

The code below plays a complete game of chess ... randomly.

<?php

require 'vendor/autoload.php';
use \Ryanhs\Chess\Chess;

$chess = new Chess();
while (!$chess->gameOver()) {
	$moves = $chess->moves();
	$move = $moves[mt_rand(0, count($moves) - 1)];
	$chess->move($move);
}

echo $chess->ascii() . PHP_EOL;

Chess.js

you can check original chess.js here

Chess.php documentation

you can check it here: https://ryanhs.github.io/chess.php

BUGS

TODO

MAINTAINER/COLLABORATOR NEEDED

As this project not in heavy development state, a maintainer/collaborator needed.
If you interested to become a collaborator, please tell me. :-)