PHPackages                             weew/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. weew/kernel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

weew/kernel
===========

Simple kernel for registration and invocation of service providers.

v2.1.2(9y ago)03461MITPHP

Since Sep 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/weew/kernel)[ Packagist](https://packagist.org/packages/weew/kernel)[ RSS](/packages/weew-kernel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (10)Used By (1)

PHP Kernel
==========

[](#php-kernel)

[![Build Status](https://camo.githubusercontent.com/4956c995e149eaded2525cb88f26b14e03b5f67318dbc07e4e3c7ea61e6f83be/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776565772f6b65726e656c2e737667)](https://travis-ci.org/weew/kernel)[![Code Quality](https://camo.githubusercontent.com/0ffebbba8a0bd5de706c852308a39595cfe867ca8d02dd4f886d61d3efdc4a76/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f776565772f6b65726e656c2e737667)](https://scrutinizer-ci.com/g/weew/kernel)[![Test Coverage](https://camo.githubusercontent.com/7ac72c0e49381ecc1cd1f3057b718a1fcd7111938074a55b4d10e971a7ce080f/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f776565772f6b65726e656c2e737667)](https://coveralls.io/github/weew/kernel)[![Version](https://camo.githubusercontent.com/7a960eb1d86b4dbd9f650ea19fae99c4fedfe4db63f3c618c7eaea326d796830/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776565772f6b65726e656c2e737667)](https://packagist.org/packages/weew/kernel)[![Licence](https://camo.githubusercontent.com/6b6a2242dbccdc9fed6c5e7e9850af05341144949389e5c8e027097cc82b47e9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776565772f6b65726e656c2e737667)](https://packagist.org/packages/weew/kernel)

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Introduction](#introduction)
- [Usage](#usage)
    - [Creating a provider](#creating-a-provider)
    - [Registering providers](#registering-providers)
    - [Initialization](#initialization)
    - [Booting](#booting)
- [Extension](#extension)
    - [Sharing data between providers](#sharing-data-between-providers)
    - [Custom container support](#custom-container-support)
- [Existing container integrations](#existing-container-integrations)
- [Related projects](#related-projects)

Installation
------------

[](#installation)

`composer require weew/kernel`

Introduction
------------

[](#introduction)

Kernel is responsible for the bootstrap process of service providers. It offers you a easy and intuitive way to register your own providers. The boot process consists of three steps - `instantiation`, `initialization` and `booting`. There is also an additional step - `shutdown`. This gives your providers a lot of flexibility on when to do what.

Usage
-----

[](#usage)

### Creating a provider

[](#creating-a-provider)

Any class can be used as a provider. If the provider has any of these methods `configure`, `initialize`, `boot`, `shutdown`, the container will invoke them accordingly. It does not require a specific interface. This is by choice, I'll explain why I chose this solution in one of the future readme updates.

```
class MyServiceProvider {}
// or
class MyServiceProvider {
    public function configure() {}
    public function initialize() {}
    public function boot() {}
    public function shutdown() {}
}
```

### Registering providers

[](#registering-providers)

It is fairly easy to create a kernel and register your own providers.

```
$kernel = new Kernel();
$kernel->addProviders([
    MyServiceProvider::class,
    AnotherServiceProvider::class,
]);
```

### Configuration

[](#configuration)

When you configure the kernel, all of its service providers get instantiated and configured.

```
$kernel->configure();
```

### Initialization

[](#initialization)

When you initialize the kernel, all of its service providers get initialized.

```
$kernel->initialize();
```

### Booting

[](#booting)

On boot, all service providers will be booted. This is a good place to setup your provider and do some work.

```
$kernel->boot();
```

### Shutdown

[](#shutdown)

This will shutdown the kernel and all of its providers.

```
$kernel->shutdown();
```

Extension
---------

[](#extension)

The kernel comes without a container. Out of the box the service providers will be very limited since they have no way to share anything. There are several workarounds for this.

### Sharing data between providers

[](#sharing-data-between-providers)

The easiest way to share data between providers is to use kernel's shared arguments.

```
class MyProvider {
    public function boot(IDictionary $shared) {
        $shared->get('container')['foo'] = 'bar';
    }
}

$kernel = new Kernel();
$container = [];
$kernel->getSharedArguments()->set('container', $container);
$kernel->addProvider(MyProvider::class);
```

### Custom container support

[](#custom-container-support)

A better way to enable container access for your providers is to replace the default implementation of the `IProviderInvoker` with your own. In this example I'll be using this powerful [container](https://github.com/weew/container).

```
class ContainerProviderInvoker implements IProviderInvoker {
    private $container;

    public function __construct(IContainer $container) {
        $this->container = $container;
    }

    public function create($providerClass, IDictionary $shared) {
        $this->container->get($providerClass, ['shared' => $shared]);
    }

    public function configure($provider, IDictionary $shared) {
        $this->container->callMethod($provider, 'configure', ['shared' => $shared]);
    }

    public function initialize($provider, IDictionary $shared) {
        $this->container->callMethod($provider, 'initialize', ['shared' => $shared]);
    }

    public function boot($provider, IDictionary $shared) {
        $this->container->callMethod($provider, 'boot', ['shared' => $shared]);
    }

    public function shutdown($provider, IDictionary $shared) {
        $this->container->callMethod($provider, 'shutdown', ['shared' => $shared]);
    }
}

$container = new Container();
$invoker = new ContainerProviderInvoker($container);
$kernel = new Kernel($invoker);
// or
$kernel->setProviderInvoker($invoker);
```

From now on all providers will benefit from constructor and method injection and will be able to share anything in the container. Depending on which container package you use the `IProviderInvoker` implementation may vary, but the idea stays the same.

Existing container integrations
-------------------------------

[](#existing-container-integrations)

There is an integration available for the [weew/container](https://github.com/weew/container) container. See [weew/kernel-container-aware](https://github.com/weew/kernel-container-aware).

Related projects
----------------

[](#related-projects)

- [PHP Container](https://github.com/weew/container) works very well together with this package.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity69

Established project with proven stability

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 ~37 days

Recently: every ~43 days

Total

9

Last Release

3633d ago

Major Versions

v0.0.1 → v1.0.02015-11-16

v1.3.0 → v2.0.02016-03-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/10b2b854b5829dd13a15967c000ed2119b5faef67aca24d94c653c8ac550d85e?d=identicon)[weew](/maintainers/weew)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[jfsimon/gmap-bundle

Symfony GMap bundle

1952.7k](/packages/jfsimon-gmap-bundle)

PHPackages © 2026

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