Skip to content

HKM KernelA modular PHP 8.4+ framework built on the Gated Demand Architecture

Security before modules. Load only what you need. Enforce isolation at runtime.

Quick Taste ​

Declare a route once — it lives in data, not PHP code:

json
{
  "routes": [
    { "method": "POST", "path": "/api/invoices", "handler": "Shop\\Http\\InvoiceController@create" }
  ]
}

Write a controller in three lines — just orchestration:

php
<?php
declare(strict_types=1);
namespace App\Http;

use AlfacodeTeam\PhpServicePlatform\Kernel\Http\{Request, Response};
use App\Invoices\API\Contracts\InvoiceServiceContract;

final class InvoiceController
{
    public function __construct(
        private InvoiceServiceContract $invoices,
    ) {}

    public function create(Request $request): Response
    {
        $dto    = CreateInvoiceDTO::fromRequest($request);
        $result = $this->invoices->create($dto);
        return Response::json($result->toArray(), 201);
    }
}

The service handles transactions, domain events, and rollback. The repository speaks only to the database. The domain layer stays pure and dependency-free. The framework enforces all of this at runtime.

Where to Go Next ​

  • Introduction — What HKM is and when you need it.
  • Installation — Get hkm installed and create your first project.
  • Gated Demand Architecture — The six core principles that drive every decision.
  • Request Lifecycle — How a request flows through the security gate, pipelines, and modules.
  • Modules — Understand module.json, the ModuleContract, and how modules work.
  • HTTP Layer — Working with immutable requests and typed responses.
  • Testing — Test patterns for domain logic, services, and full integration.
  • Deployment — Running on PHP-FPM or OpenSwoole in production.

Released under the MIT License.