PHPackages                             wiznetic/kernel - 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. [Framework](/categories/framework)
4. /
5. wiznetic/kernel

ActiveLibrary[Framework](/categories/framework)

wiznetic/kernel
===============

Programmable lifecycle microkernel by Wiznetic

v2.1.0(4w ago)0261MITPHP

Since Feb 18Pushed 4w agoCompare

[ Source](https://github.com/wiznetic-git/kernel)[ Packagist](https://packagist.org/packages/wiznetic/kernel)[ RSS](/packages/wiznetic-kernel/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (8)Used By (1)

wiznetic/kernel
===============

[](#wiznetickernel)

Programmable lifecycle microkernel. Без MVC, без routing, без controller — само execution engine с пълен контрол.

---

Инсталация
----------

[](#инсталация)

```
composer require wiznetic/kernel
```

---

Идентичност
-----------

[](#идентичност)

Пакет`wiznetic/kernel`Namespace`Wiznetic\Kernel`Версия`2.0.0`ЛицензMIT---

Файлова структура
-----------------

[](#файлова-структура)

```
src/
  Kernel.php   — lifecycle engine + dispatch
  Listing.php  — influence chaining върху listener
  Event.php    — базов клас за custom events
  Trace.php    — execution recorder

```

---

Lifecycle
---------

[](#lifecycle)

`Kernel::handle()` изпълнява фиксирана последователност от стъпки:

```
before:request  →  on:request  →  after:request
before:process  →  on:process  →  after:process
before:response →  on:response →  after:response

```

Всеки callback получава `$ctx`:

```
$ctx->request   // входящият request
$ctx->response  // изходящият response
$ctx->data      // споделени данни между hooks
$ctx->events    // dispatched events, indexed by class
```

---

API
---

[](#api)

### Standalone lifecycle hooks

[](#standalone-lifecycle-hooks)

```
Kernel::before('process', function($ctx) { /* auth */ });
Kernel::on('process',     function($ctx) { $ctx->response = '...'; });
Kernel::after('response', function($ctx) { /* log */ });

Kernel::handle($request);
```

---

### Custom events — dispatch

[](#custom-events--dispatch)

```
use Wiznetic\Kernel\Event;

class UserCreated extends Event {
    public function __construct(public readonly array $user) {}
}

// Регистрирай listener
Kernel::listen(UserCreated::class, UserCreatedHandler::class);

// Dispatch
Kernel::dispatch(new UserCreated(['id' => 1, 'name' => 'John']));
```

Handler класът имплементира `handle()`:

```
class UserCreatedHandler {
    public function handle(UserCreated $event): void {
        // $event->user
    }
}
```

Спиране на propagation:

```
class UserCreatedHandler {
    public function handle(UserCreated $event): void {
        $event->stopPropagation(); // следващите handlers не се изпълняват
    }
}
```

---

### Listing — influence методи

[](#listing--influence-методи)

`Kernel::listen()` връща `Listing` обект. Чрез него позиционираш listener-а в lifecycle-а — кога точно да се изпълни и какво да получи.

```
Kernel::listen(UserCreated::class, UserCreatedHandler::class)
    ->before('request', 'ctx')    // изпълни преди request, подай $ctx
    ->after('request',  'event')  // изпълни след request, подай event обекта
    ->on('process',     'all');   // изпълни при process, подай и двете
```

Един и същи handler клас — различни данни — различни точки от процеса.

#### Payload selector

[](#payload-selector)

СтойностHandler получава`'ctx'``$ctx` (lifecycle контекст)`'event'`Event обекта (или `null` ако не е dispatch-нат)`'all'``$ctx, $event` *(default)*`callable`ти решаваш```
// Custom payload — callable
Kernel::listen(UserCreated::class, UserCreatedHandler::class)
    ->before('process', fn($ctx, $event) => [$ctx->request, $event?->user]);
```

Handler-ът при influence получава точно това, което си декларирал:

```
class UserCreatedHandler {
    // когато receive = 'ctx'
    public function handle(object $ctx): void {}

    // когато receive = 'event'
    public function handle(?UserCreated $event): void {}

    // когато receive = 'all'
    public function handle(object $ctx, ?UserCreated $event): void {}
}
```

---

### Trace

[](#trace)

Проследява всяко изпълнение — lifecycle hook, dispatch, influence.

```
Kernel::trace(true);   // включи
Kernel::handle($req);

$log = Kernel::getTrace();
// [
//   ['phase' => 'before', 'step' => 'request',  'handler' => 'closure',            'duration' => 0.12],
//   ['phase' => 'dispatch', 'step' => 'UserCreated', 'handler' => 'UserCreatedHandler', 'duration' => 1.03],
//   ['phase' => 'on',     'step' => 'process',  'handler' => 'UserCreatedHandler', 'duration' => 0.44],
// ]

Kernel::trace(false);  // изключи
Trace::clear();        // изчисти лога
```

Всеки запис:

ПолеОписание`phase``before` / `on` / `after` / `dispatch` / `influence``step`lifecycle стъпка или event class`handler`клас или `closure``duration`ms`at``microtime(true)` timestamp---

Пълен пример
------------

[](#пълен-пример)

```
use Wiznetic\Kernel\Kernel;
use Wiznetic\Kernel\Event;

// Custom event
class OrderPlaced extends Event {
    public function __construct(public readonly int $orderId) {}
}

// Handler
class OrderHandler {
    public function handle(object $ctx, ?OrderPlaced $event): void {
        // достъп и до lifecycle ctx и до event-а
    }
}

// Регистрация
Kernel::listen(OrderPlaced::class, OrderHandler::class)
    ->before('process', 'ctx')           // преди process — само ctx
    ->after('process',  'all')           // след process — ctx + event
    ->on('response',    fn($ctx, $e) => [$e?->orderId]); // само orderId

// Standalone hook
Kernel::before('request', function($ctx) {
    $ctx->data['start'] = microtime(true);
});

// Trace
Kernel::trace(true);

// Dispatch и стартиране
Kernel::dispatch(new OrderPlaced(42));
Kernel::handle($_SERVER);

dump(Kernel::getTrace());
```

---

Архитектурни принципи
---------------------

[](#архитектурни-принципи)

- Kernel не знае за MVC, routing, controller, view
- Lifecycle е отворен — всяка стъпка е hooк-ваща
- Един handler може да участва на множество lifecycle точки с различни данни
- Trace е opt-in — нулев overhead когато е изключен
- PSR-4 autoload, без външни зависимости

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

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

Every ~17 days

Recently: every ~26 days

Total

7

Last Release

29d ago

Major Versions

v1.4.0 → v2.0.02026-04-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/72b6b44e38976134b60fc4a3328357203b842bab10cb25ee6f327aba49ac93af?d=identicon)[wiznetic](/maintainers/wiznetic)

---

Top Contributors

[![wiznetic-git](https://avatars.githubusercontent.com/u/250726010?v=4)](https://github.com/wiznetic-git "wiznetic-git (10 commits)")

### Embed Badge

![Health badge](/badges/wiznetic-kernel/health.svg)

```
[![Health](https://phpackages.com/badges/wiznetic-kernel/health.svg)](https://phpackages.com/packages/wiznetic-kernel)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M298](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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