Download the PHP package p-chess/chess-bundle without Composer

On this page you can find all versions of the php package p-chess/chess-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package chess-bundle

ChessBundle

Installation

Run composer require p-chess/chess-bundle

Local development

This project is designed to run inside Docker via docker compose, with helper targets in Makefile.

Configuration

Create a service that extends PChess\ChessBundle\HtmlOutput and implement the required methods. You probably want to inject Symfony's router service here and use it to return the required URLs. Note that each route can be provided with an identifier for your game.

Create a configuration file, and use content like the following:

This is an example of how routes can be defined (using an "id" parameter as an identifier):

Note that move_end is the only route that actually changes the state of the game, so it must not be reachable with a GET request. The board renders those squares as submit buttons of a POST form (see the "CSRF protection" paragraph below); all the other routes only display something, and stay GET.

Usage

You can inject a service implementing \PChess\ChessBundle\ChessProviderInterface in your controller, then implement different actions, using the provided \PChess\Chess\Chess object.

In your template, you can use the Twig function chess_render(chess) to render the board. If you need to pass an identifier, use chess_render(chess, identifier) instead.

The main service you can use is \PChess\ChessBundle\SessionChessProvider. This service allows you to keep chess games in session, providing the following methods:

Using $identifier is not mandatory.

To get a list of currently allowed moves (optionally limited to a $from square), use the static \PChess\ChessBundle\Mover::getAllowedMoves($chess, $from).

CSRF protection

Since ending a move is a POST request, you probably want to protect it with a CSRF token. Override the getHiddenFields() method of your output service to add any hidden field to the form wrapping the board:

Styling

You can use the provided _board.scss file to style the board:

@import '~@p-chess/chess-bundle/scss/board';

Don't forget to update your frontend files, using npm or yarn.

The final result should be something like this:

Persisting a Chess object

You can easily save a Chess object into Doctrine (or other kinds of mapping libraries), using two fields/properties: fen, and history. The first one is a simple string. The second one can be a simple_array (for Doctrine), where you should put the result of Mover::getHistoryStrings() method. When retrieving an object, you should use fen and the result of Mover::getHistoryEntries() to build back your Chess object.


All versions of chess-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
p-chess/chess Version ^1.2
symfony/config Version ^6.4 || ^7.4 || ^8.0
symfony/dependency-injection Version ^6.4 || ^7.4 || ^8.0
symfony/http-kernel Version ^6.4 || ^7.4 || ^8.0
twig/twig Version ^3.23
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package p-chess/chess-bundle contains the following files

Loading the files please wait ...