1
PHP Framework
Virgil edited this page 2026-03-11 12:14:42 +00:00
PHP Framework
Composer: lthn/php
Provider: Core\LifecycleEventProvider, Core\Lang\LangServiceProvider, Core\Bouncer\Gate\Boot
Architecture
Event-driven modular monolith framework for Laravel. Modules declare interest in lifecycle events via static $listens arrays and are only instantiated when those events fire. The LazyModuleListener defers module loading until the subscribed event is dispatched.
Module Loading
ModuleScannerdiscovers modules from configured namespace paths.ModuleRegistrytracks discovered modules and their event subscriptions.LifecycleEventProviderregisters theLazyModuleListenerthat intercepts lifecycle events and instantiates modules on demand.
Lifecycle Events
Defined in src/Core/Events/:
| Event | Purpose |
|---|---|
WebRoutesRegistering |
Public web routes |
AdminPanelBooting |
Admin panel registration |
ApiRoutesRegistering |
REST API routes |
ClientRoutesRegistering |
Authenticated SaaS routes |
ConsoleBooting |
Artisan commands |
McpToolsRegistering |
MCP tool handlers |
Namespace Mapping
| Path | Namespace |
|---|---|
src/Core/ |
Core\ |
src/Mod/ |
Core\Mod\ |
src/Plug/ |
Core\Plug\ |
src/Website/ |
Core\Website\ |
Core Services
| Directory | Description |
|---|---|
| Actions/ | Single-purpose action classes with Action trait |
| Activity/ | Activity logging integration |
| Boot.php | Core boot provider |
| Bouncer/ | Authorisation gates |
| Cdn/ | CDN integration (asset serving) |
| Config/ | Configuration management |
| Console/ | Core artisan commands |
| Crypt/ | Encryption/decryption services |
| Database/ | Database extensions, migrations |
| Events/ | Lifecycle event classes |
| Front/ | Front-end service layer |
| Headers/ | HTTP header management |
| Helpers/ | Utility functions |
| Input/ | Input validation |
| Lang/ | Internationalisation (LangServiceProvider) |
| Mail/ | Mail templates and sending |
| Media/ | Media handling, thumbnails |
| Rules/ | Validation rules |
| Search/ | Search integration |
| Seo/ | SEO meta management |
| Storage/ | Storage abstraction |
Key Classes
LifecycleEventProvider— Registers lazy module listener, dispatches lifecycle events.LazyModuleListener— Intercepts events, instantiates modules that declared interest via$listens.ModuleScanner— Discovers module classes from configured paths.ModuleRegistry— Tracks modules and their event subscriptions.Init— Core initialisation.Pro— Pro/premium feature gates.
Actions Pattern
Single-purpose business logic with static run() helper:
class CreateOrder
{
use Action;
public function handle(User $user, array $data): Order
{
return Order::create($data);
}
}
// Usage: CreateOrder::run($user, $validated);
Dependencies
PHP: laravel/framework ^11.0|^12.0, laravel/pennant ^1.0, livewire/livewire ^3.0|^4.0.
Dev: larastan, phpstan, psalm, pest, pint, rector, infection, orchestra/testbench.