{"id":15025691,"url":"https://github.com/hawkbitphp/hawkbit","last_synced_at":"2025-04-09T20:04:35.623Z","repository":{"id":62495088,"uuid":"53177035","full_name":"HawkBitPhp/hawkbit","owner":"HawkBitPhp","description":"PSR-7 Micro PHP framework - advanced derivate of Proton by Alex Bilbie","archived":false,"fork":false,"pushed_at":"2017-10-15T23:16:48.000Z","size":311,"stargazers_count":64,"open_issues_count":3,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T20:04:29.538Z","etag":null,"topics":["console-framework","event-driven","framework","http","micro-framework","middleware","php","php7","php71","psr-7","psr7-handler","psr7-middleware","web-framework"],"latest_commit_sha":null,"homepage":"https://github.com/HawkBitPhp/hawkbit","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/HawkBitPhp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-05T01:48:35.000Z","updated_at":"2024-12-12T14:24:57.000Z","dependencies_parsed_at":"2022-11-02T11:46:15.781Z","dependency_job_id":null,"html_url":"https://github.com/HawkBitPhp/hawkbit","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HawkBitPhp%2Fhawkbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HawkBitPhp%2Fhawkbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HawkBitPhp%2Fhawkbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HawkBitPhp%2Fhawkbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HawkBitPhp","download_url":"https://codeload.github.com/HawkBitPhp/hawkbit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103868,"owners_count":21048245,"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":["console-framework","event-driven","framework","http","micro-framework","middleware","php","php7","php71","psr-7","psr7-handler","psr7-middleware","web-framework"],"created_at":"2024-09-24T20:02:50.910Z","updated_at":"2025-04-09T20:04:35.600Z","avatar_url":"https://github.com/HawkBitPhp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hawkbit\\Application\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Coverage Status][ico-coveralls]][link-coveralls]\n\nHawkbit\\Application micro framework is a high customizable, event driven and compatible with \n[PSR-7](https://github.com/php-fig/http-message), \n[StackPHP](http://stackphp.com/) and \n[Zend Stratigility](https://github.com/zendframework/zend-stratigility).\n\nHawkbit\\Application uses latest versions of [League\\Route](https://github.com/thephpleague/route) for routing, \n[League\\Container](https://github.com/thephpleague/container) for dependency injection, \n[League\\Event](https://github.com/thephpleague/event) for event dispatching,\n[Zend Config](https://docs.zendframework.com/zend-config/) for configuration.\n\nHawkbit\\Application is an advanced derivate of [Proton](https://github.com/alexbilbie/Proton) and part of Hawkbit\\Application Component collection by Marco Bunge. Hawkbit\\Application 1.x is also known as Blast Hawkbit\\Application.\n\n### Quick start\n\nPlease see [public/](public/) for example usage and read documentation.\n\n### Integrations\n\nHawkbit\\Application delivers also optional packages:\n\n - Database: [`hawkbit/database`](https://github.com/HawkBitPhp/hawkbit-database)\n - Doctrine ORM Wrapper: [`hawkbit/doctrine`](https://github.com/HawkBitPhp/hawkbit-doctrine)\n - Plates View Engine: [`hawkbit/presentation`](https://github.com/HawkBitPhp/hawkbit-presentation)\n\n## Motivation\n\n\u003e My vision is to provide a micro framework which is able to handle HTTP and CLI in the same fashion. The developer should be able to reuse it's code, design it's business layer by his needs. Hawkbit should be a supporting tool instead of predefined framework. And yes it is under active development.\n\u003e\n\u003e I love PSR, phpleague und a minimal set of dependecies and want to create a micro framework which is used the best packages out there and bundeld in a nice application layer. I'm also love the style of component-based development.\n\u003e\n\u003e Hawkbit is built on top phpleague packages and keep PSR in mind. Hawkbit is designed to co-exist whith your code instead of replace code base. Hawkbit does has a small dependency footprint. Last but not least Hawkbit does not force the developer how to design the application bussiness logic, since we prefer to use POPO's for Controllers / Commands (the accessor to bussiness logic).\n\u003e\n\u003e At the moment I design and develop all Hawkbit packages and manage the whole codebase. I would be appreciate for support or even better: for contributors!\n\nPlease refer to [Issue #33](https://github.com/HawkBitPhp/hawkbit/issues/33) for details.\n\n## Special thanks\n\nThank you for PR, identifing Bus, or any other Improvements!\n\n- [designcise](https://github.com/designcise)\n- [Vitalij Mik](https://github.com/BlackScorp)\n\n## Install\n\n### Using Composer\n\nHawkbit\\Application is available on [Packagist](https://packagist.org/packages/hawkbit/hawkbit) and can be installed using [Composer](https://getcomposer.org/). This can be done by running the following command or by updating your `composer.json` file.\n\n```bash\ncomposer require hawkbit/hawkbit\n```\n\ncomposer.json\n\n```javascript\n{\n    \"require\": {\n        \"hawkbit/hawkbit\": \"~2.0\"\n    }\n}\n```\n\nBe sure to also include your Composer autoload file in your project:\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n```\n\n### Downloading .zip file\n\nThis project is also available for download as a `.zip` file on GitHub. Visit the [releases page](https://github.com/hawkbit/hawkbit/releases), select the version you want, and click the \"Source code (zip)\" download button.\n\n### Requirements\n\nThe following versions of PHP are supported by this version.\n\n* PHP 5.5\n* PHP 5.6\n* PHP 7.0\n* PHP 7.1\n* HHVM\n\n## Setup\n\nCreate a new app\n\n```php\n\u003c?php\n\nrequire __DIR__.'/../vendor/autoload.php';\n\n$app = new \\Hawkbit\\Application();\n```\n\nCreate a new app with configuration\n\n```php\n\u003c?php\n\n$config = [\n    'key' =\u003e 'value'\n];\n$app = new \\Hawkbit\\Application($config);\n```\n\nAdd routes\n\n```php\n\u003c?php\n\n/** @var Hawkbit\\Application $app */\n$app-\u003eget('/', function ($request, $response) {\n    $response-\u003egetBody()-\u003ewrite('\u003ch1\u003eIt works!\u003c/h1\u003e');\n    return $response;\n});\n\n$app-\u003eget('/hello/{name}', function ($request, $response, $args) {\n    $response-\u003egetBody()-\u003ewrite(\n        sprintf('\u003ch1\u003eHello, %s!\u003c/h1\u003e', $args['name'])\n    );\n    return $response;\n});\n```\n\nRun application\n\n```php\n\u003c?php\n\n$app-\u003erun();\n```\n\nSee also our example at `/public/index.php`.\n\n## Configuration\n\nAdd additional configuration to application\n \nHawkbit\\Application Configuration is managed by [zend-config](https://docs.zendframework.com/zend-config/).\n\n```php\n\u003c?php\n\n//add many values\n$app-\u003esetConfig([\n    'database' =\u003e [\n        'default' =\u003e 'mysql://root:root@localhost/acmedb',\n    ],\n    'services' =\u003e [\n        'Acme\\Services\\ViewProvider',\n    ]\n]);\n\n//add a single value\n$app-\u003esetConfig('baseurl', 'localhost/');\n\n$app-\u003egetConfig()-\u003ebaseurl = 'localhost/';\n$app-\u003egetConfig()['baseurl'] = 'localhost/';\n```\n\nAccess configuration\n\n```php\n\u003c?php\n\n//access all configuration\n$app-\u003egetConfig();\n\n//get configuration item\n$default = $app-\u003egetConfig('database')-\u003edefault; // returns 'mysql://root:root@localhost/acmedb\n$default = $app-\u003egetConfig()-\u003edatabase-\u003edefault; // returns 'mysql://root:root@localhost/acmedb\n$default = $app-\u003egetConfig('database')['default']; // returns 'mysql://root:root@localhost/acmedb\n$default = $app-\u003egetConfig()['database']['default']; // returns 'mysql://root:root@localhost/acmedb\n```\n\n## Middlewares\n\nHawkbit\\Application middlewares allows advanced control of lifecycle execution.\n\n```php\n\u003c?php\n\n$app-\u003eaddMiddleware(new Acme\\SomeMiddleware);\n```\n\nHawkbit\\Application uses it's own runner `Hawkbit\\Application\\MiddelwareRunner`\n\n## Routing\n\nHawkbit\\Application uses routing integration of `league/route` and allows access to route collection methods directly.\n\nBasic usage with anonymous functions:\n\n```php\n\u003c?php\n// index.php\n\n$app-\u003eget('/', function ($request, $response) {\n    $response-\u003egetBody()-\u003ewrite('\u003ch1\u003eIt works!\u003c/h1\u003e');\n    return $response;\n});\n\n$app-\u003eget('/hello/{name}', function ($request, $response, $args) {\n    $response-\u003egetBody()-\u003ewrite(\n        sprintf('\u003ch1\u003eHello, %s!\u003c/h1\u003e', $args['name'])\n    );\n    return $response;\n});\n\n$app-\u003erun();\n```\n\n#### Access app from anonymous function\n\nHawkbit\\Application allows to access itself from anonymous function through closure binding.\n\n```php\n\u003c?php\n\n$app-\u003eget('/hello/{name}', function ($request, $response, $args) {\n    \n    // access Hawkbit\\Application\n    $app = $this;\n    \n    $response-\u003egetBody()-\u003ewrite(\n        sprintf('\u003ch1\u003eHello, %s!\u003c/h1\u003e', $args['name'])\n    );\n    return $response;\n});\n\n```\n\nBasic usage with controllers:\n\n```php\n\u003c?php\n\nrequire __DIR__.'/../vendor/autoload.php';\n\n$app = new Hawkbit\\Application();\n\n$app-\u003eget('/', 'HomeController::index'); // calls index method on HomeController class\n\n$app-\u003erun();\n```\n\n```php\n\u003c?php\n\n// HomeController.php\n\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Message\\ResponseInterface;\n\nclass HomeController\n{\n    public function index(ServerRequestInterface $request, ResponseInterface $response, array $args)\n    {\n        $response-\u003egetBody()-\u003ewrite('\u003ch1\u003eIt works!\u003c/h1\u003e');\n        return $response;\n    }\n}\n```\n\nAutomatic constructor injection of controllers:\n\n```php\n\u003c?php\n\n// index.php\n\nrequire __DIR__.'/../vendor/autoload.php';\n\n$app = new Hawkbit\\Application();\n\n$app-\u003egetContainer()-\u003eadd('CustomService', new CustomService);\n$app-\u003eget('/', 'HomeController::index'); // calls index method on HomeController class\n\n$app-\u003erun();\n```\n\n*Please use boot method in Service Providers for correct injection of services into controller!*\n\n```php\n\u003c?php\n\n// HomeController.php\n\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Message\\ResponseInterface;\n\nclass HomeController\n{\n    /**\n     * @var CustomService\n     */\n    private $service;\n\n    /**\n     * @param CustomService $application\n     */\n    public function __construct(CustomService $service = null)\n    {\n        $this-\u003eservice = $service;\n    }\n\n    /**\n     * @return CustomService\n     */\n    public function getService()\n    {\n        return $this-\u003eservice;\n    }\n    \n    public function index(ServerRequestInterface $request, ResponseInterface $response, array $args)\n    {\n        //do somehing with service\n        $service = $this-\u003egetService();\n        return $response;\n    }\n}\n```\n\nFor more information about routes [read this guide](http://route.thephpleague.com/)\n\n### Route groups\n\nHawkbit\\Application add support for route groups. \n\n```php\n\u003c?php\n\n$app-\u003egroup('/admin', function (\\League\\Route\\RouteGroup $route) {\n\n    //access app container (or any other method!)\n    $app = $this;\n    \n    $route-\u003emap('GET', '/acme/route1', 'AcmeController::actionOne');\n    $route-\u003emap('GET', '/acme/route2', 'AcmeController::actionTwo');\n    $route-\u003emap('GET', '/acme/route3', 'AcmeController::actionThree');\n});\n```\n\n#### Available vars\n\n- `$route` - `\\League\\Route\\RouteGroup`\n- `$this` - `\\Hawkbit\\Application`\n\n## Middleware integrations\n\n### StackPHP\n\nBasic usage with StackPHP (using `Stack\\Builder` and `Stack\\Run`):\n\n```php\n\u003c?php\n\n// index.php\nrequire __DIR__.'/../vendor/autoload.php';\n\n$app = new Hawkbit\\Application();\n\n$app-\u003eget('/', function ($request, $response) {\n    $response-\u003esetContent('\u003ch1\u003eHello World\u003c/h1\u003e');\n    return $response;\n});\n\n$httpKernel = new Hawkbit\\Application\\Symfony\\HttpKernelAdapter($app);\n\n$stack = (new \\Stack\\Builder())\n    -\u003epush('Some/MiddleWare') // This will execute first\n    -\u003epush('Some/MiddleWare') // This will execute second\n    -\u003epush('Some/MiddleWare'); // This will execute third\n\n$app = $stack-\u003eresolve($httpKernel);\n\\Stack\\run($httpKernel); // The app will run after all the middlewares have run\n```\n\n### Zend Stratigility\n\nBasic usage with Stratigility (using `Zend\\Stratigility\\MiddlewarePipe`):\n\n```php\n\u003c?php\n\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Zend\\Diactoros\\ServerRequestFactory;\nuse Hawkbit\\Application;\nuse Hawkbit\\Application\\Stratigility\\MiddlewarePipeAdapter;\n\n$application = new Application();\n$application-\u003eget('/', function($request, ResponseInterface $response){\n    $response-\u003egetBody()-\u003ewrite('Hello World');\n});\n$middleware = new MiddlewarePipeAdapter($application);\n\n//wrap html heading\n$middleware-\u003epipe('/', function($request, ResponseInterface $response, $next){\n    $response-\u003egetBody()-\u003ewrite('\u003ch1\u003e');\n\n    /** @var ResponseInterface $response */\n    $response = $next($request, $response);\n\n    $response-\u003egetBody()-\u003ewrite('\u003c/h1\u003e');\n});\n\n/** @var ResponseInterface $response */\n$response = $middleware(ServerRequestFactory::fromGlobals(), $application-\u003egetResponse());\n\necho $response-\u003egetBody(); //prints \u003ch1\u003eHello World\u003c/h1\u003e\n\n```\n\n## Error handling\n\nHawkbit\\Application uses \u003ca href=\"https://github.com/filp/whoops\" target=\"_blank\"\u003eWhoops\u003c/a\u003e error handling framework and determines the error handler by request content type.\n\nSet your own handler:\n\n```php\n\u003c?php\n\n$app-\u003egetErrorHandler()-\u003epush(new Acme\\ErrorResponseHandler);\n```\n\nBy default Hawkbit\\Application runs with error options disabled. To enable debugging add\n\n```php\n\u003c?php\n\n$app-\u003esetConfig('error', true);\n```\n\nBy default Hawkbit\\Application is catching all errors. To disable error catching add\n\n```php\n\u003c?php\n\n$app-\u003esetConfig('error.catch', false);\n```\n\n## Console\n\nThe console application inherit all methods from Http Application except routing and PSR-7 handling and capturing. \nIn addition to http application, the console application does not support all events (Refer to events for more \ninformation!)\n\n## Logging\n\nHawkbit\\Application has built in support for Monolog. To access a channel call:\n\n```php\n\u003c?php\n\n$app-\u003egetLogger('channel name');\n```\n\nFor more information about channels read this guide - [https://github.com/Seldaek/monolog/blob/master/doc/usage.md#leveraging-channels](https://github.com/Seldaek/monolog/blob/master/doc/usage.md#leveraging-channels).\n\n## Events\n\nYou can intercept requests and responses at seven points during the lifecycle. You can manipulate Request, Response and \nErrorResponse via `Hawkbit\\ApplicationEvent`.\n\n### Application event\n\n```php\n\u003c?php\n\n/** @var \\Hawkbit\\Application\\ApplicationEvent $event */\n\n// custom params\n$event-\u003egetParamCollection(); // returns a mutable \\ArrayObject\n\n// access application\n$event-\u003egetApplication();\n\n```\n\n### request.received\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_REQUEST_RECEIVED, function (\\Hawkbit\\Application\\ApplicationEvent $event) {\n    $request = $event-\u003egetRequest();\n    \n    // manipulate $request\n    \n    $event-\u003esetRequest($request);\n});\n```\n\nThis event is fired when a request is received but before it has been processed by the router.\n\n### response.created\n\n*Not available for Console applications!*\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_RESPONSE_CREATED, function (\\Hawkbit\\Application\\ApplicationEvent $event) {\n    $request = $event-\u003egetRequest();\n    $response = $event-\u003egetResponse();\n        \n    // manipulate request or response\n    \n    $event-\u003esetRequest($request);\n    $event-\u003esetResponse($response);\n});\n```\n\nThis event is fired when a response has been created but before it has been output.\n\n### response.sent\n\n*Not available for Console applications! Please use `shutdown`*\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_RESPONSE_SENT, function (\\Hawkbit\\Application\\ApplicationEvent $event) {\n    $request = $event-\u003egetRequest();\n    $response = $event-\u003egetResponse();\n    \n    // manipulate request or response\n    \n    $event-\u003esetRequest($request);\n    $event-\u003esetResponse($response);\n});\n```\n\nThis event is fired when a response has been output and before the application lifecycle is completed. Not available for Console Applications!\n\n### runtime.error\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_RUNTIME_ERROR, function (\\Hawkbit\\Application\\ApplicationEvent $event, $exception) use ($app) {\n    //process exception\n});\n```\n\nThis event is always fired when an error occurs.\n\n### lifecycle.error\n\n*Not available for Console applications! Please use `runtime.error`*\n\n`$errorResponse` is used as default response\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_LIFECYCLE_ERROR, function (\\Hawkbit\\Application\\ApplicationEvent $event, \\Exception $exception) {\n    $errorResponse = $event-\u003egetErrorResponse();\n \n    //manipulate error response and process exception\n        \n    $event-\u003esetErrorResponse($errorResponse);\n});\n```\n\nThis event is fired only when an error occurs while handling request/response lifecycle. \nThis event is fired after runtime.error\n\n### lifecycle.complete\n\n*Not available for Console applications! Please use `shutdown`*\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_LIFECYCLE_COMPLETE, function (\\Hawkbit\\Application\\ApplicationEvent $event) {\n    // access the request using $event-\u003egetRequest()\n    // access the response using $event-\u003egetResponse()\n});\n```\n\nThis event is fired when a response has been output and before the application lifecycle is completed.\n\n### shutdown\n\n```php\n\u003c?php\n\n$app-\u003eaddListener($app::EVENT_SHUTDOWN, function (\\Hawkbit\\Application\\ApplicationEvent $event, $response, $terminatedOutputBuffers = []) {\n    // access the response using $event-\u003egetResponse()\n    // access terminated output buffer contents\n    // or force application exit()\n});\n```\n\nThis event is always fired after each operation is completed or failed.\n\n### Custom Events\n\nYou can fire custom events using the event emitter directly:\n\n```php\n\u003c?php\n\n// addListener\n$app-\u003eaddListener('custom.event', function ($event, $time) {\n    return 'the time is '.$time;\n});\n\n// or with class addListener\n$app-\u003eaddListener(Acme\\Event::class, function (Acme\\Event $event, $time) {\n    return 'the time is '.$time;\n});\n\n// Publish\n$app-\u003egetEventEmitter()-\u003eemit('custom.event', time());\n```\n\n## Dependency Injection Container\n\nHawkbit\\Application uses `League/Container` as its dependency injection container.\n\nYou can bind singleton objects into the container from the main application object using ArrayAccess:\n\n```php\n\u003c?php\n/** @var Hawkbit\\Application $app */\n$app['db'] = function () use($app) {\n    $config = $app-\u003egetConfig('database');\n    $manager = new Illuminate\\Database\\Capsule\\Manager;\n\n    $manager-\u003eaddConnection([\n        'driver'    =\u003e 'mysql',\n        'host'      =\u003e $config['host'],\n        'database'  =\u003e $config['name'],\n        'username'  =\u003e $config['user'],\n        'password'  =\u003e $config['pass'],\n        'charset'   =\u003e 'utf8',\n        'collation' =\u003e 'utf8_unicode_ci'\n    ], 'default');\n\n    $manager-\u003esetAsGlobal();\n\n    return $manager;\n};\n```\n\nor by container access:\n\n```php\n\u003c?php\n/** @var Hawkbit\\Application $app */\n$app-\u003egetContainer()-\u003eshare('db', function () use($app) {\n    $config = $app-\u003egetConfig('database');\n    $manager = new Illuminate\\Database\\Capsule\\Manager;\n\n    $manager-\u003eaddConnection([\n        'driver'    =\u003e 'mysql',\n        'host'      =\u003e $config['db_host'],\n        'database'  =\u003e $config['db_name'],\n        'username'  =\u003e $config['db_user'],\n        'password'  =\u003e $config['db_pass'],\n        'charset'   =\u003e 'utf8',\n        'collation' =\u003e 'utf8_unicode_ci'\n    ], 'default');\n\n    $manager-\u003esetAsGlobal();\n\n    return $manager;\n});\n```\n\nMultitons can be added using the `add` method on the container:\n\n```php\n\u003c?php\n\n//callback\n$app-\u003egetContainer()-\u003eadd('foo', function () {\n    return new Foo();\n});\n```\n\nService providers can be registered using the `register` method on the Hawkbit\\Application app or `addServiceProvider` on the container:\n\n```php\n\u003c?php\n\n$app-\u003eregister('\\My\\Service\\Provider');\n$app-\u003egetContainer()-\u003eaddServiceProvider('\\My\\Service\\Provider');\n```\n\nFor more information about service providers check out this page - [http://container.thephpleague.com/service-providers/](http://container.thephpleague.com/service-providers/).\n\nFor easy testing down the road it is recommended you embrace constructor injection:\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eadd('Bar', function () {\n        return new Bar();\n});\n\n$app-\u003egetContainer()-\u003eadd('Foo', function () use ($app) {\n        return new Foo(\n            $app-\u003egetContainer()-\u003eget('Bar')\n        );\n});\n```\n\n### Container\n\nSet your own container needs an instance of `\\League\\Container\\ContainerInterface`\n\n```php\n\u003c?php\n\n$app-\u003esetContainer($container);\n```\n\nGet container\n\n```php\n\u003c?php\n\n$app-\u003egetContainer();\n```\n\n## Services\n\nHawkbit\\Application uses dependency injection container to access services. Following integrations can be exchanged.\n\n### Configurator\n\nUses in `Application::setConfig()`,`Application::getConfig()` and `Application::hasConfig()`\n\n```php\n\u003c?php\n\n$app-\u003egetConfigurator();\n``` \n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eshare(\\Zend\\Config\\Config::class, new \\Zend\\Config\\Config([], true));\n```\n\n### error handler\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eshare(\\Whoops\\Run::class, new \\Whoops\\Run());\n```\n\n```php\n\u003c?php\n\n$app-\u003egetErrorHandler();\n``` \n\n### error response handler\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eshare(\\Whoops\\Handler\\HandlerInterface::class, Acme\\ErrorResponseHandler::class);\n```\n\n```php\n\u003c?php\n\n$app-\u003egetErrorResponseHandler();\n``` \n\n### psr logger\n\nGet a new logger instance by channel name\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eadd(\\Psr\\Log\\LoggerInterface::class, \\Monolog\\Logger::class);\n```\n\n```php\n\u003c?php\n\n$app-\u003egetLogger('channel name');\n``` \n\nGet a list of available logger channels\n\n```php\n\u003c?php\n\n$app-\u003egetLoggerChannels();\n```\n\n### psr server request\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eshare(\\Psr\\Http\\Message\\ServerRequestInterface::class, \\Zend\\Diactoros\\ServerRequestFactory::fromGlobals());\n```\n\n```php\n\u003c?php\n\n$app-\u003egetRequest();\n``` \n\n### psr response\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eadd(\\Psr\\Http\\Message\\ResponseInterface::class, \\Zend\\Diactoros\\Response::class);\n```\n\n```php\n\u003c?php\n\n$app-\u003egetRequest();\n``` \n\n### response emitter\n\n```php\n\u003c?php\n\n$app-\u003egetContainer()-\u003eshare(\\Zend\\Diactoros\\Response\\EmitterInterface::class, \\Zend\\Diactoros\\Response\\SapiEmitter::class);\n```\n\n```php\n\u003c?php\n\n$app-\u003egetResponseEmitter();\n``` \n\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email \u003cmjls@web.de\u003e instead of using the issue tracker.\n\n## Credits\n\n- [Marco Bunge](https://github.com/mbunge)\n- [Alex Bilbie](https://github.com/alexbilbie) (Proton)\n- [All contributors](https://github.com/hawkbit/hawkbit/graphs/contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/hawkbit/hawkbit.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/HawkBitPhp/hawkbit/master.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/hawkbit/hawkbit.svg?style=flat-square\n[ico-coveralls]: https://img.shields.io/coveralls/HawkBitPhp/hawkbit/master.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/hawkbit/hawkbit\n[link-travis]: https://travis-ci.org/HawkBitPhp/hawkbit\n[link-downloads]: https://packagist.org/packages/hawkbit/hawkbit\n[link-author]: https://github.com/mbunge\n[link-contributors]: ../../contributors\n[link-coveralls]: https://coveralls.io/github/HawkBitPhp/hawkbit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhawkbitphp%2Fhawkbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhawkbitphp%2Fhawkbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhawkbitphp%2Fhawkbit/lists"}