laikait / laika-engine
Laika PHP Framework Engine: core, routing, models, relay container, sessions, auth, cache, queue, mail, security and CLI in one package
Requires
- php: >=8.1
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-pdo: *
- aws/aws-sdk-php: 3.394.*
- filp/whoops: 2.18.*
- firebase/php-jwt: 7.1.*
- geoip2/geoip2: ^3
- phpmailer/phpmailer: ^7.1
- twig/twig: 3.28.*
Requires (Dev)
- composer/composer: ^2.0
- dealerdirect/phpcodesniffer-composer-installer: ^1.1
- friendsofphp/php-cs-fixer: ^3.89
- phpcompatibility/php-compatibility: dev-develop
- phpunit/phpunit: ^10.5
- squizlabs/php_codesniffer: ^4.0.2
Suggests
- ext-memcached: To use the memcached cache or session driver
- ext-pcntl: Enables graceful shutdown and per-job timeout in the queue worker (Linux/macOS only)
- ext-posix: Required alongside pcntl for signal handling (Linux/macOS only)
- ext-redis: To use the redis cache, session or queue driver
- league/oauth2-client: Required only if you use PHPMailer's bundled OAuth class for XOAUTH2
Provides
None
Conflicts
None
Replaces
None
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
-
Replace the requirements in the project's
composer.json:"require": { "php": ">=8.1", "laikait/laika-engine": "2.0.*" }
-
Point the scripts at the new namespace:
"post-autoload-dump": [ "@php laika app:sync" ]
app:syncwrites bothlaikaandworkernow, so the separateScriptHandler::generateentries 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. -
Prefix every framework import with
Engine\, for exampleuse Laika\Route\Url;becomesuse 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'
-
Move
index.phpintopublic/and point the web server's document root atpublic/.php laika app:syncwritespublic/.htaccess, andphp laika nginx:serveremits a complete server block rooted atpublic/.
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\Request → Laika\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) andMailManager::extendMailer()/extendReader()register backends by name. - Macros:
Model,Blueprint,Request,Response,CacheandUrluseLaika\Engine\Support\Macroable, soModel::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 stayfinal, 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