PHPackages                             p-chess/chess-bundle - 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. p-chess/chess-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

p-chess/chess-bundle
====================

Provide integration with p-chess/chess library

v1.3.1(1mo ago)535MITPHPPHP ^8.2CI passing

Since Jan 5Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/p-chess/chess-bundle)[ Packagist](https://packagist.org/packages/p-chess/chess-bundle)[ Docs](https://github.com/p-chess/)[ RSS](/packages/p-chess-chess-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (17)Versions (8)Used By (0)

ChessBundle
===========

[](#chessbundle)

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

[](#installation)

Run `composer require p-chess/chess-bundle`

Configuration
-------------

[](#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:

```
# config/packages/chess.yaml
chess:
    output_service: App\YourOutputService
```

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

```
# config/routes.yaml
move_start:
    path: /{id}/move/{from}
    methods: GET
    controller: ... # your controller action

move_cancel:
    path: /{id}
    methods: GET
    controller: ... # your controller action

move_promotion:
    path: /{id}/promote/{from}/{to}
    methods: GET
    controller: ... # your controller action

move_end:
    path: /{id}/move/{from}/{to}/{promotion}
    methods: GET
    controller: ... # your controller action
    defaults:
        promotion: ~
```

Usage
-----

[](#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:

- `getChess($identifier, $fen)` to get main `\PChess\Chess\Chess` instance (as provided by interface)
- `restart($identifier)` to restart the game
- `save($identifier)` to save the game in session
- `reverse($identifier)` to switch sides
- `getAllowedMoves($chess, $from)` to get a list of currently allowed moves (optionally limited to `$from` square)

Using `$identifier` is not mandatory.

### Styling

[](#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:

[![](https://user-images.githubusercontent.com/179866/114995898-92cf1b80-9e9e-11eb-8e99-75a60bbba6bd.png)](https://user-images.githubusercontent.com/179866/114995898-92cf1b80-9e9e-11eb-8e99-75a60bbba6bd.png)

### Persisting a Chess object

[](#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.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~110 days

Total

5

Last Release

58d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.3.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d191f9ff3aa52357cb523c9eec3553d267128fc75e0faf9dca74f289f6604f54?d=identicon)[garak](/maintainers/garak)

![](https://www.gravatar.com/avatar/5d00e1e73a4ff379162b943421469055929a95e7a6ce4c3808976dcc1fa28f4f?d=identicon)[akondas](/maintainers/akondas)

---

Top Contributors

[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (20 commits)")

---

Tags

bundlechessphpsymfony-bundlesymfonychess

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/p-chess-chess-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/p-chess-chess-bundle/health.svg)](https://phpackages.com/packages/p-chess-chess-bundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[pentatrion/vite-bundle

Vite integration for your Symfony app

2755.3M13](/packages/pentatrion-vite-bundle)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[pugx/autocompleter-bundle

Add an autocomplete type to forms

93861.6k3](/packages/pugx-autocompleter-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
