{"id":21569217,"url":"https://github.com/symlex/di-microkernel","last_synced_at":"2025-04-10T14:06:29.012Z","repository":{"id":57012616,"uuid":"82660417","full_name":"symlex/di-microkernel","owner":"symlex","description":"A dependency injection micro-kernel for bootstrapping PHP applications","archived":false,"fork":false,"pushed_at":"2019-01-02T15:17:54.000Z","size":38,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T12:47:45.938Z","etag":null,"topics":["bootstrap","dependency-injection","di-container","kernel","micro-framework","php-library","symfony"],"latest_commit_sha":null,"homepage":"https://docs.symlex.org","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/symlex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-21T09:22:11.000Z","updated_at":"2022-04-03T18:10:38.000Z","dependencies_parsed_at":"2022-08-21T13:40:50.944Z","dependency_job_id":null,"html_url":"https://github.com/symlex/di-microkernel","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symlex%2Fdi-microkernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symlex%2Fdi-microkernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symlex%2Fdi-microkernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symlex%2Fdi-microkernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/symlex","download_url":"https://codeload.github.com/symlex/di-microkernel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248231883,"owners_count":21069422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","dependency-injection","di-container","kernel","micro-framework","php-library","symfony"],"created_at":"2024-11-24T11:07:31.971Z","updated_at":"2025-04-10T14:06:28.993Z","avatar_url":"https://github.com/symlex.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro-Kernel for PHP Applications\n\n[![Latest Stable Version](https://poser.pugx.org/symlex/di-microkernel/v/stable.svg)](https://packagist.org/packages/symlex/di-microkernel)\n[![License](https://poser.pugx.org/symlex/di-microkernel/license.svg)](https://packagist.org/packages/symlex/di-microkernel)\n[![Test Coverage](https://codecov.io/gh/symlex/di-microkernel/branch/master/graph/badge.svg)](https://codecov.io/gh/symlex/di-microkernel)\n[![Build Status](https://travis-ci.org/symlex/di-microkernel.png?branch=master)](https://travis-ci.org/symlex/di-microkernel)\n[![Documentation](https://readthedocs.org/projects/symlex-docs/badge/?version=latest\u0026style=flat)](https://docs.symlex.org/en/latest/di-microkernel)\n\nThis library contains a micro-kernel for bootstrapping almost any PHP application, including [Silex](https://silex.symfony.com/),\n[Symlex](https://github.com/symlex/symlex) (a framework stack for agile Web development based on Symfony) \nand [Symfony Console](https://symfony.com/doc/current/components/console.html). \nThe kernel itself is just a few lines to set a bunch of environment parameters and create a service container \ninstance with that.\n\n![Micro-Kernel Architecture](https://docs.symlex.org/en/latest/di-microkernel/img/architecture.svg)\n\n## Run an App ##\n\nCreating a kernel instance and calling `run()` is enough to start an application:\n\n```php\n#!/usr/bin/env php\n\u003c?php\n\n// Composer\nrequire_once 'vendor/autoload.php'; \n\n$app = new \\DIMicroKernel\\Kernel('console');\n\n// Run the 'app' service defined in config/console.yml\n$app-\u003erun(); \n```\n\n## Configuration ##\n\nYAML files located in `config/` configure the application and all of it's dependencies as a service. The filename matches \nthe application's environment name (e.g. `config/console.yml`). The configuration can additionally be modified \nfor sub environments such as local or production by providing a matching config file like `config/console.local.yml`\n(see `app.sub_environment` parameter). These files are in the same [well documented](https://symfony.com/doc/current/components/dependency_injection.html) format you might know from Symfony:\n\n```yaml\nparameters:\n    app.name: 'My App'\n    app.version: '1.0'\n\nservices:\n    doctrine.migrations.migrate:\n        class: Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\MigrateCommand\n        \n    app:\n        class: Symfony\\Component\\Console\\Application\n        public: true\n        arguments: [%app.name%, %app.version%]\n        calls:\n            - [ add, [ \"@doctrine.migrations.migrate\" ] ]\n```\n\nThis provides a uniform approach for bootstrapping Web applications like `Silex\\Application`,\n`Symlex\\Application\\Web` or command-line applications like `Symfony\\Component\\Console\\Application` using the same kernel. \nThe result is much cleaner and leaner than the usual bootstrap and configuration madness you know from many frameworks.\n\n## Parameters ##\n\nThe kernel sets a number of default parameters that can be used for configuring services. The default values can be \nchanged via setter methods of the kernel or overwritten/extended by container config files \nand environment variables (e.g. `url: '%env(DATABASE_URL)%'`).\n\nParameter           | Getter method         | Setter method         | Default value            \n--------------------|-----------------------|-----------------------|------------------\napp.name            | getName()             | setName()             | 'Kernel'\napp.version         | getVersion()          | setVersion()          | '1.0'\napp.environment     | getEnvironment()      | setEnvironment()      | 'app'\napp.sub_environment | getSubEnvironment()   | setSubEnvironment()   | 'local'\napp.debug           | isDebug()             | setDebug()            | false\napp.charset         | getCharset()          | setCharset()          | 'UTF-8'\napp.path            | getAppPath()          | setAppPath()          | './'\napp.config_path     | getConfigPath()       | setConfigPath()       | './config'\napp.base_path       | getBasePath()         | setBasePath()         | '../'\napp.storage_path    | getStoragePath()      | setStoragePath()      | '../storage'\napp.log_path        | getLogPath()          | setLogPath()          | '../storage/log'\napp.cache_path      | getCachePath()        | setCachePath()        | '../storage/cache'\napp.src_path        | getSrcPath()          | setSrcPath()          | '../src'\n\n## Customization ##\n\nThe kernel base class can be extended to customize it for a specific purpose such as long running console applications:\n\n```php\n\u003c?php\n\nuse DIMicroKernel\\Kernel;\n\nclass ConsoleApp extends Kernel\n{\n    public function __construct($appPath, $debug = false)\n    {\n        parent::__construct('console', $appPath, $debug);\n    }\n\n    public function setUp()\n    {\n        set_time_limit(0);\n        ini_set('memory_limit', '-1');\n    }\n}\n```\n\n## Caching ##\n\nIf 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: \n\n```yaml\nparameters:\n    container.cache: false\n```\n\n## Composer ##\n\nTo use this library in your project, simply run `composer require symlex/di-microkernel` or\nadd \"symlex/di-microkernel\" to your [composer.json](https://getcomposer.org/doc/04-schema.md) file and run `composer update`:\n\n```json\n{\n    \"require\": {\n        \"php\": \"\u003e=7.1\",\n        \"symlex/di-microkernel\": \"^2.0\"\n    }\n}\n```\n\n## About ##\n\nDIMicroKernel is maintained by [Michael Mayer](https://blog.liquidbytes.net/about/).\nFeel free to send an e-mail to [hello@symlex.org](mailto:hello@symlex.org) if you have any questions, \nneed [commercial support](https://blog.liquidbytes.net/contact/) or just want to say hello. \nWe welcome contributions of any kind. If you have a bug or an idea, read our \n[guide](CONTRIBUTING.md) before opening an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymlex%2Fdi-microkernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymlex%2Fdi-microkernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymlex%2Fdi-microkernel/lists"}