Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Chess Laravel Package

p-chess/chess

A PHP chess library for Laravel and standalone use. Parse FEN/PGN, generate and validate legal moves, handle castling, en passant and promotion, and detect check, checkmate and stalemate through a clean object-oriented API. Ideal for building chess apps, bots and analysis tools.

Deep Wiki
Context7

p-chess is a pure-PHP chess library that handles the rules of the game so you don't have to. It offers a clean API for representing positions, generating legal moves, and validating game state, making it a solid foundation for chess apps, engines, or analysis tools.

  • Legal move generation with full rule support, including castling, en passant, and promotion
  • FEN and PGN import/export for positions and games
  • Check, checkmate, and stalemate detection
  • Immutable board model with intuitive, chainable methods
  • Well-tested PSR-compatible code with no external dependencies
Frequently asked questions about Chess
How do I install p-chess/chess in a Laravel application?
Install it with Composer using composer require p-chess/chess and confirm the version constraint resolves against your PHP runtime. The package is described as a domain library rather than a Laravel package, so do not expect a service provider or published config. Register your own adapter or interface binding in a service provider and keep package classes out of controllers and Eloquent models.
Does p-chess/chess support Laravel 10 and Laravel 11?
Laravel version support depends on the package's PHP requirement rather than a Laravel-specific constraint, since it is a framework-agnostic PHP chess engine. It should work on Laravel 10 or 11 with PHP 8.x, but verify the Composer metadata before committing. Run a short spike on your target Laravel version and pin the package version in composer.lock.
How do I validate a chess move with p-chess/chess in Laravel?
Wrap the package behind an application-owned interface, for example a ChessService with a validateMove method, and call that from your action or job. The engine should own board state and legality rules, while your Laravel layer handles authorization, persistence, and HTTP responses. Keep DTOs for board and move data so package objects do not leak into API resources.
How do I import and export FEN and PGN with p-chess/chess?
The package description states it supports FEN and PGN import and export, along with board representation. Treat PGN parsing as untrusted input: enforce size limits, catch exceptions, and test malformed or hostile games. Verify FEN round-trips with fixtures before relying on stored positions.
Does p-chess/chess handle castling, en passant, promotion, and checkmate?
The overview says it covers common chess rules and legal move generation, which should include special moves and game-ending states. Because chess correctness is deterministic and easy to get subtly wrong, build a golden-master test set for castling rights, en passant, promotion, check, checkmate, and stalemate. Confirm the exact coverage in the package's tests and source before production use.
Is p-chess/chess production ready given its low star count?
It has modest adoption signals, so treat it as a dependency you may need to fork or vendor. The MIT license is favorable and the domain is well understood, which lowers replacement cost. Run a time-boxed spike, pin the version, and keep a fallback path until behavior is proven on real game data.
How does p-chess/chess perform when generating all legal moves or parsing large PGN files?
Move generation and PGN processing are CPU-bound, so performance depends on board complexity and file size. Benchmark validation of a single move separately from full legal move generation and bulk PGN parsing. For analysis or imports, push work to queued jobs and set memory limits and timeouts.
Is p-chess/chess safe to use with Laravel Octane and queue workers?
There is no implied Laravel service provider or global state contract, but you should still check for static caches or mutable shared state in the engine. Prefer instantiating per-game state explicitly rather than binding a mutable singleton. Test under Octane and long-running queue workers to confirm requests do not leak board state.
How should I test a chess engine integration in Laravel?
Build fixtures covering legal and illegal moves, castling edge cases, en passant, promotion, checkmate, stalemate, and malformed PGN. If you are replacing existing chess logic, run both implementations in parallel on stored games and compare legal moves, FEN round-trips, and PGN output. Use feature tests around your adapter rather than asserting on package internals.
What are alternatives to p-chess/chess for a Laravel chess app?
Alternatives include writing a small in-house board and rules layer, using another PHP chess library, or delegating analysis to an external engine such as Stockfish over UCI. The package is best suited as an in-process engine for board state and legality checks, not a full analysis service. Keep your adapter interface narrow so you can swap implementations later.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource