PHPackages                             php-di/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. php-di/kernel

ActiveLibrary[Framework](/categories/framework)

php-di/kernel
=============

Kernel for PHP-DI applications

0.4.1(8y ago)1076011MITPHPPHP ^7.0

Since Jan 3Pushed 8y ago3 watchersCompare

[ Source](https://github.com/PHP-DI/Kernel)[ Packagist](https://packagist.org/packages/php-di/kernel)[ Docs](http://php-di.org)[ RSS](/packages/php-di-kernel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (8)Dependencies (3)Versions (9)Used By (1)

PHP-DI application kernel
=========================

[](#php-di-application-kernel)

Kernel for building modules with [PHP-DI](http://php-di.org).

[![Build Status](https://camo.githubusercontent.com/fa8f5c4fd3c4e2ca35ef5d60cc394bc232910815d13ed4e8fe857724898020ea/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5048502d44492f4b65726e656c2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/PHP-DI/Kernel)[![Coverage Status](https://camo.githubusercontent.com/78ecc60d7dce15403d3702a70768daa3cac83e1082bdefa8ccf679c5b7086df4/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f5048502d44492f4b65726e656c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/PHP-DI/Kernel?branch=master)

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

[](#introduction)

The Kernel let's you build an application based on PHP-DI modules.

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

[](#installation)

```
composer require php-di/kernel

```

Usage
-----

[](#usage)

The kernel's role is to create the container. It does so by registering all the configuration files of the modules we ask it to load:

```
$kernel = new Kernel([
    'twig/twig',
    'doctrine/dbal',
    'vendor/app',
]);

$container = $kernel->createContainer();
```

If you want to register configuration on the container, you can:

- create a module - this is the recommended solution, read the next sections to learn more
- or set the configuration directly - this is useful in micro-frameworks or micro-applications:

    ```
    $kernel = new Kernel();
    $kernel->addConfig([
        'db.host' => 'localhost',
    ]);
    ```

### Installing a module

[](#installing-a-module)

To install a 3rd party module:

- install the package using Composer
- add it to the list of modules your kernel will load, for example:

    ```
    $kernel = new Kernel([
        'twig/twig',
    ]);
    ```

### Creating a module

[](#creating-a-module)

1. the Composer package name is the module name
2. create a resource directory in your package, usually `res/`
3. create as many PHP-DI configuration files as needed in `res/config/`

That's it. Here is what your package should look like:

```
res/
    config/
        config.php
    ...
src/
    ...
composer.json

```

When the module is registered in the kernel like this:

```
$kernel = new Kernel([
    'foo/bar',
]);
```

all the files in `vendor/foo/bar/res/config/*.php` will be loaded.

**Your main application will probably contain configuration files too: it is also a module**. Since it may not have a package name in `composer.json` you will need to set one. You can name it `app`, for example:

```
{
    "name": "app",
    "require": {
        // ...
    }
}
```

That way you can let the kernel load your application as a module:

```
$kernel = new Kernel([
    'app',
]);
```

### Environments

[](#environments)

Applications often need to behave differently according to the environment: `dev`, `prod`, etc.

PHP-DI's Kernel let you write config for specific environments through a simple convention:

```
res/
    config/
        config.php
        env/
            dev.php
            prod.php
    ...

```

You can then instruct the environment to load:

```
$kernel = new Kernel($modules, 'dev'); // dev environment
$kernel = new Kernel($modules, 'prod'); // prod environment
```

Note that **environments are optional**.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Recently: every ~98 days

Total

8

Last Release

3275d ago

PHP version history (2 changes)0.1.0PHP ^5.5|^7.0

0.3.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/329a6111724074f5388e95dd41a03ccf3c43f4bfe1ecf27c94c9efc6f7823228?d=identicon)[mnapoli](/maintainers/mnapoli)

---

Top Contributors

[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (36 commits)")

---

Tags

php-dipsr-11applicationkernelphp-di

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k79](/packages/elgg-elgg)[duxweb/dux-lite

The lightweight framework based on slim php

161.0k9](/packages/duxweb-dux-lite)

PHPackages © 2026

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