Search by

laikait / laika-engine

riyadhtayf

Laika PHP Framework Engine: core, routing, models, relay container, sessions, auth, cache, queue, mail, security and CLI in one package

Package info

github.com/laikait/laika-engine

pkg:composer/laikait/laika-engine

Statistics

Installs: 13

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.0 2026-09-20 10:18 UTC

This package is auto-updated.

Last update: 2026-09-20 10:24:38 UTC


README

The whole Laika PHP Framework runtime in one Composer package. It replaces the separate laikait/laika-* packages.

composer require laikait/laika-engine

Requires PHP 8.1+ with ext-json, ext-mbstring, ext-openssl and ext-pdo.

Modules

Everything lives under the Laika\Engine\ namespace. Core's classes sit directly under it (Laika\Engine\Http\Request, Laika\Engine\App\Template, …); every other module has its own segment.

Module Namespace Replaces Docs
Core Laika\Engine\* (App, Http, Helper, Support, …) laikait/laika-core docs/core
Route Laika\Engine\Route laikait/laika-route docs/route
Relay Laika\Engine\Relay laikait/laika-relay docs/relay
Services Laika\Engine\Services laikait/laika-relay (services) docs/relay
Model Laika\Engine\Model laikait/laika-model docs/model
Session Laika\Engine\Session laikait/laika-session docs/session
Auth Laika\Engine\Auth laikait/laika-auth docs/auth
Cache Laika\Engine\Cache laikait/laika-cache docs/cache
Queue Laika\Engine\Queue laikait/laika-queue docs/queue
Mailman Laika\Engine\Mailman laikait/laika-mailman docs/mailman
Shield Laika\Engine\Shield laikait/laika-shield docs/shield
Cli Laika\Engine\Cli laikait/laika-cli docs/cli

The package ships two executables, bin/laika (CLI) and bin/worker (queue worker). A Laika project also gets root-level laika and worker proxies, which Composer generates through the project's post-autoload-dump scripts.

Migrating from the laika-* packages

  1. Replace the requirements in the project's composer.json:

    "require": {
        "php": ">=8.1",
        "laikait/laika-engine": "2.0.*"
    }
  2. Point the scripts at the new namespace:

    "post-autoload-dump": [
        "@php laika app:sync"
    ]

    app:sync writes both laika and worker now, so the separate ScriptHandler::generate entries are no longer needed. Leaving them in place still works — they call the same generator and find the files already current — but they can be deleted.

  3. Prefix every framework import with Engine\, for example use Laika\Route\Url; becomes use Laika\Engine\Route\Url;. This one-liner does it for a whole project:

    grep -rlP 'Laika\\+(Auth|Cache|Cli|Core|Mailman|Model|Queue|Relay|Route|Session|Shield|Service)\b' \
        lf-* public template | xargs perl -pi -e \
        's/Laika(\\+)Core(\\+)/Laika$1Engine$2/g; s/Laika(\\+)Service\b/Laika$1Engine$1Services/g; s/Laika(\\+)(Auth|Cache|Cli|Mailman|Model|Queue|Relay|Route|Session|Shield)\b/Laika$1Engine$1$2/g'
  4. Move index.php into public/ and point the web server's document root at public/. php laika app:sync writes public/.htaccess, and php laika nginx:server emits a complete server block rooted at public/.

Upgrading to 2.0

Core's classes moved up one level: Laika\Engine\Core\X is now Laika\Engine\X (for example Laika\Engine\Core\Http\RequestLaika\Engine\Http\Request). Laika\Engine\Core\Model\OptionModel is now Laika\Engine\Model\OptionModel. Nothing else was renamed. Require "laikait/laika-engine": "2.0.*", then run:

grep -rlP 'Laika\\+Engine\\+Core\\+' lf-* public template | xargs perl -pi -e \
    's/Laika(\\+)Engine(\\+)Core(\\+)/Laika$1Engine$2/g'

Extending

  • Drivers: Cache::extend(), HandlerFactory::extend() (sessions), Queue::extend() / Queue::extendFailed(), DriverFactory::extend() (database) and MailManager::extendMailer() / extendReader() register backends by name.
  • Macros: Model, Blueprint, Request, Response, Cache and Url use Laika\Engine\Support\Macroable, so Model::macro('active', fn () => ...) adds a method. Relays forward macros too.
  • Subclassing: framework classes are open and their steps are protected. Security boundaries (Route\Asset, ProxyTrust, the Shield detectors and rules), value objects and internal parts stay final, and say why.

The framework docs cover each in detail, under "Extending the Framework".

Package resources

A package can declare the same resource from several directories by giving a list. Laika Engine does this for relays:

"extra": {
    "laika": {
        "resources": {
            "relays": [
                {"path": "src/Cache/Relay", "namespace": "...", "contract": "..."},
                {"path": "src/Shield/Relay", "namespace": "...", "contract": "..."}
            ]
        }
    }
}

Development

composer install
composer test

Each module's suite runs in its own process, because the suites need different APP_PATH values (see phpunit.xml.dist).

License

MIT