PHPackages                             javleds/turn-engine-laravel - 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. javleds/turn-engine-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

javleds/turn-engine-laravel
===========================

Reusable Laravel backend for online turn-based board games.

v0.1.0(today)00MITPHPPHP ^8.3

Since Jun 20Pushed todayCompare

[ Source](https://github.com/javleds/laravel-game-engine)[ Packagist](https://packagist.org/packages/javleds/turn-engine-laravel)[ Docs](https://github.com/javleds/laravel-game-engine)[ RSS](/packages/javleds-turn-engine-laravel/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Game Engine
===================

[](#laravel-game-engine)

Reusable Laravel backend package for online turn-based board games.

This package owns the generic server-side engine: rooms, players, lobby lifecycle, chat, persisted game state, command execution, event history, and realtime broadcast events. It does not contain rules for a specific board game. A host application provides the game definition, setup handler, policy, command handlers, and player-facing view factory.

Spanish documentation is available in [README.es.md](README.es.md).

Repository Links
----------------

[](#repository-links)

Official repositories:

- Laravel backend package:
- Vue frontend package:

Package Pair
------------

[](#package-pair)

This package is the backend half of the engine. It is designed to be used with the Vue client package, `@javleds/vue-turn-engine`, but the HTTP and realtime contracts can also be consumed by another frontend.

```
@startuml
skinparam componentStyle rectangle

package "Host game app" {
  [Game Definition]
  [Game Rules]
  [Game Views]
  [Laravel Controllers]
}

package "javleds/laravel-game-engine" {
  [Rooms]
  [Players]
  [Chat]
  [Command Runner]
  [Realtime Events]
  [Engine Models]
}

package "@javleds/vue-turn-engine" {
  [Room Repositories]
  [Chat Repositories]
  [Session Store]
  [Realtime Composables]
}

[Laravel Controllers] --> [Rooms]
[Game Definition] --> [Command Runner]
[Game Rules] --> [Command Runner]
[Command Runner] --> [Realtime Events]
[@javleds/vue-turn-engine] --> [Laravel Controllers]
@enduml
```

Responsibilities
----------------

[](#responsibilities)

The engine package provides:

- Room creation, joining, leaving, reconnect, disconnect, and start flows.
- Player token authentication for room-scoped actions.
- Engine-owned Eloquent models for rooms, players, states, events, and chat messages.
- Generic chat services and realtime broadcast events.
- A command registry and command runner for game-specific actions.
- Contracts for game definitions, setup, policy checks, and state views.
- Package migrations and Laravel service provider auto-discovery.

The host game provides:

- Game rules and command handlers.
- Initial setup logic and deterministic state seed handling.
- Room policy limits such as player count and start requirements.
- Public/private game state view shaping.
- HTTP controllers or routes that expose the engine services.
- Frontend UI and game-specific action repositories.

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

[](#installation)

For local development with a sibling checkout:

```
{
  "repositories": [
    {
      "type": "path",
      "url": "../laravel-game-engine",
      "options": {
        "symlink": true
      }
    }
  ],
  "require": {
    "javleds/laravel-game-engine": "dev-main"
  }
}
```

Then run:

```
composer update javleds/laravel-game-engine --with-dependencies
php artisan migrate
```

For Packagist usage, replace the path repository with the official package version once the repository is published.

Laravel Setup
-------------

[](#laravel-setup)

The service provider is auto-discovered through Composer:

```
{
  "extra": {
    "laravel": {
      "providers": [
        "TurnEngine\Laravel\TurnEngineServiceProvider"
      ]
    }
  }
}
```

Publish config only if the host app wants a local config file:

```
php artisan vendor:publish --tag=turn-engine-config
```

The host application must register at least one `GameDefinition` in `TurnEngine\Laravel\GameRegistry`.

```
use App\Games\MyGame\MyGameDefinition;
use TurnEngine\Laravel\GameRegistry;

$this->app->singleton(GameRegistry::class, function (): GameRegistry {
    return new GameRegistry([
        $this->app->make(MyGameDefinition::class),
    ]);
});
```

If more than one game is registered, configure the default game key:

```
return [
    'default_game' => 'my-game',
];
```

Core Contracts
--------------

[](#core-contracts)

A game adapter implements these contracts:

- `GameDefinition`: stable game key, ruleset version, policy, setup handler, command registry, and view factory.
- `GamePolicy`: room size and lifecycle checks.
- `GameSetupHandler`: initial state creation when a room starts.
- `GameViewFactory`: public/private state projection for API responses.
- `CommandHandler`: game-specific state transition for a command payload.

The dependency direction is always host game -&gt; engine contracts. The engine does not depend on host game classes.

Backend / Frontend Contract
---------------------------

[](#backend--frontend-contract)

The Vue package expects the host app to expose compatible HTTP endpoints for room, chat, and game state flows. The current engine services are transport-agnostic enough to sit behind Laravel controllers, API resources, or another HTTP layer.

Realtime events use room channels and these event names:

- `.room.state.changed`
- `.room.chat.message.created`

The frontend package must be configured with the host realtime client, usually Laravel Echo.

Publishing Checklist
--------------------

[](#publishing-checklist)

Before publishing this package publicly:

- Review the MIT license and update it if a different distribution model is required.
- Tag a semantic version, for example `v0.1.0`.
- Add CI for PHP syntax, static checks, and package install smoke tests.

Current Status
--------------

[](#current-status)

This package is extracted and usable as a local Composer path package. It is not tied to the Giants game domain.

Quality Checks
--------------

[](#quality-checks)

Run package metadata validation before publishing:

```
composer validate --strict
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65b67fec8f0713fe42ce0c110d8969d35cbc74b952f514197d06ef0b69345fdb?d=identicon)[javleds](/maintainers/javleds)

---

Top Contributors

[![javleds](https://avatars.githubusercontent.com/u/11241239?v=4)](https://github.com/javleds "javleds (9 commits)")

---

Tags

laravelrealtimeBoard Gamegame-engineturn-based

### Embed Badge

![Health badge](/badges/javleds-turn-engine-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/javleds-turn-engine-laravel/health.svg)](https://phpackages.com/packages/javleds-turn-engine-laravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)

PHPackages © 2026

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