Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 43 | All time: 10,860 This week: 206![]() |
Version | License | PHP version | Categories | |||
chess-bundle 1.0.0 | Custom (specified... | 5 | PHP 5, Libraries, Games |
Run composer require p-chess/chess-bundle
Create a service that extends PChess\ChessBundle\HtmlOutput
and
implements required methods.
You probably want to inject Symfony's router service here, and use it
to return required URLs.
Note that each route can be provided with an identifier for your game.
Create a configuration file, and use a 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 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: ~
You can inject a service implementing \PChess\ChessBundle\ChessProviderInterface
in your controller, then
implement different actions, using provided \PChess\Chess\Chess
object.
In your template, you can use 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 following methods:
Using $identifier
is not mandatory.
You can use 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:
<img src="https://user-images.githubusercontent.com/179866/114995898-92cf1b80-9e9e-11eb-8e99-75a60bbba6bd.png" alt="">
You can easily save a Chess
object into Doctrine (or other kind 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.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() ![]() |
Example | Example script | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.