2017 © Pedro Peláez
 

library di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

image

lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  • Saturday, July 7, 2018
  • by lastzero
  • Repository
  • 1 Watchers
  • 2 Stars
  • 259 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Micro-Kernel for PHP Applications

Latest Stable Version License Test Coverage Build Status Documentation, (*1)

This library contains a micro-kernel for bootstrapping almost any PHP application, including Silex, Symlex (a framework stack for agile Web development based on Symfony) and Symfony Console. The kernel itself is just a few lines to set a bunch of environment parameters and create a service container instance with that., (*2)

Micro-Kernel Architecture, (*3)

Run an App

Creating a kernel instance and calling run() is enough to start an application:, (*4)

#!/usr/bin/env php
<?php

// Composer
require_once 'vendor/autoload.php'; 

$app = new \DIMicroKernel\Kernel('console');

// Run the 'app' service defined in config/console.yml
$app->run(); 

Configuration

YAML files located in config/ configure the application and all of it's dependencies as a service. The filename matches the application's environment name (e.g. config/console.yml). The configuration can additionally be modified for sub environments such as local or production by providing a matching config file like config/console.local.yml (see app.sub_environment parameter). These files are in the same well documented format you might know from Symfony:, (*5)

parameters:
    app.name: 'My App'
    app.version: '1.0'

services:
    doctrine.migrations.migrate:
        class: Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand

    app:
        class: Symfony\Component\Console\Application
        public: true
        arguments: [%app.name%, %app.version%]
        calls:
            - [ add, [ "@doctrine.migrations.migrate" ] ]

This provides a uniform approach for bootstrapping Web applications like Silex\Application, Symlex\Application\Web or command-line applications like Symfony\Component\Console\Application using the same kernel. The result is much cleaner and leaner than the usual bootstrap and configuration madness you know from many frameworks., (*6)

Parameters

The kernel sets a number of default parameters that can be used for configuring services. The default values can be changed via setter methods of the kernel or overwritten/extended by container config files and environment variables (e.g. url: '%env(DATABASE_URL)%')., (*7)

Parameter Getter method Setter method Default value
app.name getName() setName() 'Kernel'
app.version getVersion() setVersion() '1.0'
app.environment getEnvironment() setEnvironment() 'app'
app.sub_environment getSubEnvironment() setSubEnvironment() 'local'
app.debug isDebug() setDebug() false
app.charset getCharset() setCharset() 'UTF-8'
app.path getAppPath() setAppPath() './'
app.config_path getConfigPath() setConfigPath() './config'
app.base_path getBasePath() setBasePath() '../'
app.storage_path getStoragePath() setStoragePath() '../storage'
app.log_path getLogPath() setLogPath() '../storage/log'
app.cache_path getCachePath() setCachePath() '../storage/cache'
app.src_path getSrcPath() setSrcPath() '../src'

Customization

The kernel base class can be extended to customize it for a specific purpose such as long running console applications:, (*8)

<?php

use DIMicroKernel\Kernel;

class ConsoleApp extends Kernel
{
    public function __construct($appPath, $debug = false)
    {
        parent::__construct('console', $appPath, $debug);
    }

    public function setUp()
    {
        set_time_limit(0);
        ini_set('memory_limit', '-1');
    }
}

Caching

If debug mode is turned off, the service container configuration is cached by the kernel in the directory set as cache path. You have to delete all cache files after updating the configuration. To disable caching completely, add container.cache: false to your configuration parameters:, (*9)

parameters:
    container.cache: false

Composer

To use this library in your project, simply run composer require symlex/di-microkernel or add "symlex/di-microkernel" to your composer.json file and run composer update:, (*10)

{
    "require": {
        "php": ">=7.1",
        "symlex/di-microkernel": "^2.0"
    }
}

About

DIMicroKernel is maintained by Michael Mayer. Feel free to send an e-mail to hello@symlex.org if you have any questions, need commercial support or just want to say hello. We welcome contributions of any kind. If you have a bug or an idea, read our guide before opening an issue., (*11)

The Versions

07/07 2018

dev-master

9999999-dev https://github.com/symlex/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

07/07 2018

v2.0.1

2.0.1.0 https://github.com/symlex/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

06/07 2018

v2.0.0

2.0.0.0 https://github.com/symlex/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

12/06 2018

v1.4.0

1.4.0.0 https://github.com/symlex/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

12/09 2017

v1.3.1

1.3.1.0 https://github.com/symlex/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

05/04 2017

v1.3.0

1.3.0.0 https://github.com/symlex/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

05/04 2017

v1.2.0

1.2.0.0 https://github.com/lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

09/03 2017

v1.1.1

1.1.1.0 https://github.com/lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

08/03 2017

v1.1.0

1.1.0.0 https://github.com/lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

03/03 2017

v1.0.3

1.0.3.0 https://github.com/lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

22/02 2017

v1.0.2

1.0.2.0 https://github.com/lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

22/02 2017

v1.0.1

1.0.1.0 https://github.com/lastzero/di-microkernel

A micro-kernel based on the Symfony service container for bootstrapping almost any PHP application

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework

21/02 2017

v1.0.0

1.0.0.0 https://github.com/lastzero/di-microkernel

A versatile DI micro-kernel for PHP applications

  Sources   Download

MIT

The Requires

 

The Development Requires

dependency injection lumen silex symfony performance micro-framework