{"id":21759938,"url":"https://github.com/psr-framework/di","last_synced_at":"2025-07-19T04:31:21.431Z","repository":{"id":56982716,"uuid":"279549868","full_name":"PSR-Framework/di","owner":"PSR-Framework","description":"Very simple PSR-11 DI Container for PHP 7.4+","archived":false,"fork":false,"pushed_at":"2020-07-22T15:32:50.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-30T20:05:09.642Z","etag":null,"topics":["dependency-injection","framework","php","php7","psr-11"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSR-Framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-14T10:07:09.000Z","updated_at":"2022-07-12T20:22:15.000Z","dependencies_parsed_at":"2022-08-21T12:20:15.208Z","dependency_job_id":null,"html_url":"https://github.com/PSR-Framework/di","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSR-Framework%2Fdi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSR-Framework%2Fdi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSR-Framework%2Fdi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSR-Framework%2Fdi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSR-Framework","download_url":"https://codeload.github.com/PSR-Framework/di/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226535093,"owners_count":17647561,"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":["dependency-injection","framework","php","php7","psr-11"],"created_at":"2024-11-26T11:36:33.389Z","updated_at":"2024-11-26T11:36:34.083Z","avatar_url":"https://github.com/PSR-Framework.png","language":"PHP","readme":"## DI Container\n\nVery simple PSR-11 DI Container for PHP 7.4+\n\n[![Latest Version](https://img.shields.io/github/release/Furious-PHP/di.svg?style=flat-square)](https://github.com/Furious-PHP/di/releases)\n[![Build Status](https://scrutinizer-ci.com/g/Furious-PHP/di/badges/build.png?b=master)](https://scrutinizer-ci.com/g/Furious-PHP/di/build-status/master)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/Furious-PHP/di/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)\n[![Quality Score](https://img.shields.io/scrutinizer/g/Furious-PHP/di.svg?style=flat-square)](https://scrutinizer-ci.com/g/Furious-PHP/di)\n[![Maintainability](https://api.codeclimate.com/v1/badges/71ecfc66e6100d3ffa0d/maintainability)](https://codeclimate.com/github/Furious-PHP/di/maintainability)\n[![Total Downloads](https://poser.pugx.org/furious/container/downloads)](https://packagist.org/packages/furious/container)\n[![Monthly Downloads](https://poser.pugx.org/furious/container/d/monthly.png)](https://packagist.org/packages/furious/container)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\nInstall:\n\n    composer require furious/container\n\nUse:\n\n    $container = new Container();\n    \n    // get\n    \n    $container-\u003eget('key');\n    \n    // has\n    \n    $container-\u003ehas('key');\n    \n    // put integers\n    $container-\u003eset(1, 100);\n    $container-\u003eput(2, 200); // use set or put\n    \n    // put string\n    $container-\u003eset('some string', 'some value');\n    \n    // put array\n    $container-\u003eset('config', [\n        'debug' =\u003e true,\n        'some key' =\u003e 'some value'\n    ]);\n    \n    // put clojure\n    // return SomeClass instance\n    $container-\u003eset(SomeClass::class, function (ContainerInterface $container) {\n        return new SomeClass();\n    });\n    \n    // put object\n    $container-\u003eset(SomeAnotherClass::class, new SomeAnotherClass('value', 'value'));\n    \n    // autowiring\n    \n    class A\n    {\n        public function __construct(B $b)\n        {\n        }\n    }\n    \n    class B\n    {\n    \n    }\n    \n    $container-\u003eget(A::class);\n    \n    // Factories\n    \n    class Factory\n    {\n        public function __invoke(ContainerInterface $container)\n        {\n            return ExampleClass(\n                $container-\u003eget('key'),\n                $container-\u003eget('key'),\n                $container-\u003eget('key'),\n                $container-\u003eget('key')\n            );\n        }\n    }\n    \n    $container-\u003eset(ExampleClass::class, function (ContainerInterface $container) {\n        return (new Factory())($container);\n    });\n    \n    // Interfaces\n    \n    interface SomeInterface\n    {\n    \n    }\n    \n    class SomeClass implements SomeInterface\n    {\n        \n    }\n    \n    $container-\u003eget(SomeInterface::class, function (ContainerInterface $container) {\n        return $container-\u003eget(SomeClass::class);\n    });","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsr-framework%2Fdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsr-framework%2Fdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsr-framework%2Fdi/lists"}