{"id":15025620,"url":"https://github.com/ph-7/simple-ph-dic","last_synced_at":"2025-04-09T20:04:36.608Z","repository":{"id":57038423,"uuid":"147129399","full_name":"pH-7/Simple-PH-DIC","owner":"pH-7","description":"🌈 PH's DIC is a Simple PHP 7.1+ Dependency Injection Container (DIC) Library","archived":false,"fork":false,"pushed_at":"2025-01-27T00:41:59.000Z","size":32,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T20:04:28.611Z","etag":null,"topics":["clean-architecture","clean-code","clean-php","container","dependecy-injection","dependency-injection","dependency-injection-container","di","dic","php","php-71","php71","programming"],"latest_commit_sha":null,"homepage":"https://github.com/pH-7/simple-PH-DIC","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pH-7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"phenry","github":"pH-7"}},"created_at":"2018-09-02T23:29:44.000Z","updated_at":"2025-01-27T00:42:03.000Z","dependencies_parsed_at":"2025-02-15T19:41:54.185Z","dependency_job_id":null,"html_url":"https://github.com/pH-7/Simple-PH-DIC","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pH-7%2FSimple-PH-DIC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pH-7%2FSimple-PH-DIC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pH-7%2FSimple-PH-DIC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pH-7%2FSimple-PH-DIC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pH-7","download_url":"https://codeload.github.com/pH-7/Simple-PH-DIC/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":["clean-architecture","clean-code","clean-php","container","dependecy-injection","dependency-injection","dependency-injection-container","di","dic","php","php-71","php71","programming"],"created_at":"2024-09-24T20:02:41.883Z","updated_at":"2025-04-09T20:04:36.581Z","avatar_url":"https://github.com/pH-7.png","language":"PHP","readme":"# P.H.'s Dependency Injection Container Library\n\n![PHP Dependency Injection Container](dependency-injection.svg)\n\n## Summary ⏳\nThe \"P.H.'s DIC\" is a simple and lightweight PHP 7.1+ **Dependency Injection Container**'s library which lets you manage your dependencies easily for your next great project 🎉\n\n\n## Requirements ⚙\n\n* 🐘 [PHP 7.1](http://php.net/releases/7_1_0.php) or newer\n* 🎻 [Composer](https://getcomposer.org)\n\n\n## Installation 📓\n\n```bash\ncomposer require ph-7/dependency-injection-container\n```\n\n\n## Usage 🎮\n\nRegister your new DIC as below (FYI, for this example I use the [Symfony's HttpFoundation](https://packagist.org/packages/symfony/http-foundation) Request).\n\n\nFor the first example, let's create your provider class with an [anonymous class](http://php.net/manual/en/language.oop5.anonymous.php) that implements the `\\PierreHenry\\Container\\Providable` interface.\n\n```php\nuse PierreHenry\\Container\\Container;\nuse PierreHenry\\Container\\Providable;\nuse Symfony\\Component\\HttpFoundation\\Request;\n\n$container = new Container();\n\n// Register your container\n$container-\u003eregister(\n    'example.symfony.httprequest',\n    new class implements Providable\n    {\n        public function getService(): Request\n        {\n            return Request::createFromGlobals();\n        }\n    }\n);\n\n// Retrieve the container\n$httpRequest = $container-\u003eget('example.symfony.httprequest');\n\n// Use it\n$request = $httpRequest-\u003erequest; // $_POST body params\nif ($request-\u003eget('get_var')) {\n    echo '$_POST[\"get var\"] exists';\n} else {\n    echo '\"get_var\" has not been requested';\n}\n```\n\n### Another Example... 🎯\n\n```php\nuse DateTime;\nuse DateTimeZone;\nuse PierreHenry\\Container\\Container;\nuse PierreHenry\\Container\\Providable;\n\n$container = new Container();\n$container-\u003eregister(\n    'stubs.date.datetime',\n    new class implements Providable\n    {\n        public function getService(): DateTime\n        {\n            return new DateTime('now', new DateTimeZone('America/Chicago'));\n        }\n    }\n);\n\n// Retrieve the container\n$date = $container-\u003eget('stubs.date.datetime');\n\n// Use it\necho $date-\u003eformat('m-d-Y H:i:s');\n```\n\n\n## Inspired By... 🧠\n\nThis project is highly inspired by my [DIC](https://github.com/Lifyzer/Lifyzer-WebApp-CMS/tree/master/Server/Core/Container) I built for another [side-project](https://lifyzer.com).\n\n\n## ...Who Am I...? 🤔\n\n[![Pierre-Henry Soria](https://avatars0.githubusercontent.com/u/1325411?s=200)](http://pierrehenry.be \"My personal website :-)\")\n\nHi there! 😉 I'm [Pierre-Henry Soria](http://ph7.me), \"[PierreHenry.be](http://pierrehenry.be)™\": a cool passionate Belgian software engineer :belgium: :smiley:\n\nYou can keep in touch with me at *hi {{AT}} ph7 [[D0T]] me*!\n\n\n## Passion Drives Me! 🚀\n\nLove programming! 😊 Check out other exciting projects I previously did such as **[Lifyzer Healthy Food](https://github.com/Lifyzer)**, which gives lots of details about what you eat and allow you do scan your food items 🌯\nAnother project I'm proud of is the **[Social Dating WebApp Builder Project](https://github.com/pH7Software/)** I started 8 years ago ☀️\n\n\n## License ⚖\n\nUnder [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.en.html) or later.\n","funding_links":["https://ko-fi.com/phenry","https://github.com/sponsors/pH-7"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph-7%2Fsimple-ph-dic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fph-7%2Fsimple-ph-dic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph-7%2Fsimple-ph-dic/lists"}