{"id":18649813,"url":"https://github.com/ashwanthkumar/ioc-php","last_synced_at":"2025-11-05T10:30:31.257Z","repository":{"id":2000154,"uuid":"2933506","full_name":"ashwanthkumar/ioc-php","owner":"ashwanthkumar","description":"Simple Inversion of Control system in PHP, implemented as a part of my final year project. ","archived":false,"fork":false,"pushed_at":"2016-01-16T16:22:25.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T12:44:52.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"TylerFisher/commencement","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashwanthkumar.png","metadata":{"files":{"readme":"README.markdown","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":"2011-12-07T15:40:43.000Z","updated_at":"2024-08-28T15:25:18.000Z","dependencies_parsed_at":"2022-07-21T13:18:22.408Z","dependency_job_id":null,"html_url":"https://github.com/ashwanthkumar/ioc-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashwanthkumar%2Fioc-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashwanthkumar%2Fioc-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashwanthkumar%2Fioc-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashwanthkumar%2Fioc-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashwanthkumar","download_url":"https://codeload.github.com/ashwanthkumar/ioc-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239456408,"owners_count":19641843,"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":[],"created_at":"2024-11-07T06:40:45.215Z","updated_at":"2025-11-05T10:30:31.217Z","avatar_url":"https://github.com/ashwanthkumar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n# IoC (Inversion of Control) Module of BlueIgnis\n#### Written by Ashwanth Kumar \\\u003cashwanth@ashwanthkumar.in\\\u003e\n#### Version 0.1\n\n## Introduction\nAn attempt to create a dependency injection for PHP. Current this module independently implements a IoC container (called Registry) for storing all the Services and their corresponding object to service the request which can be injected dynamically. \n\n## Design Goal:\n- Add an Annotation @Inject(\"ServiceName\") to dynamically assign the value of the property or object from our little IoC (Inversion of Control) Registry. \n- Create a Registry of Services, which are loaded and can always be re-used anytime in the code using @Inject(\"ServiceName\")\n\nThis module uses [**ARO**](https://github.com/ashwanthkumar/aro-php \"Visit ARO project website\") in *BlueIgnis* for implementing @Inject style dependency injection. For normal independent usages refer **Usages Example**\n\n##  Usage Examples:\n\n### Add a service to the IoC Container\n\t// Load the IoC Module\n\trequire_once(\"/path/to/lib/ioc/IoC.php\");\n\t\n\t// Create a DB Connection\n\t$dao = new PDO($dsn, $user, $pass);\n\n\t// Get the Registry Instance\n\t$container = Registry::get();\n\t$container-\u003eaddService(\"DAO\", $dao, \"DB Connection\");\t// Valid\n\t\n\t// throws ServiceNameAlreadyTakenException Exception\n\t$container-\u003eaddService(\"DAO\", new stdClass, \"Another sample Object Instance\");\n\n \n### Get a particular Service\n\t// Load the IoC Module\n\trequire_once(\"/path/to/lib/ioc/IoC.php\");\n\t\n\t// Get the Registry Instance\n\t$registry = Registry::get();\n\t$db = $registry-\u003egetService(\"DAO\");\t// Valid\n\t$db = $registry-\u003egetService(\"DoNotExist\"); // throws ServiceNotFound Exception\n\n\n### Get all the services\n\t// Load the IoC Module\n\trequire_once(\"/path/to/lib/ioc/IoC.php\");\n\n\t// Get the Registry Instance\n\t$registry = Registry::get();\n\t$service_list = $registry-\u003elistAll();\n\n\t// Loop through the list of services and display its properties\n\tforeach($service_list as $service) {\n\t\techo $service['name'] . '\\n'; \t\t// Name of the service\n\t\t$obj = $service['object'] . '\\n'; \t// Object Instance\n\t\techo $service['description'] . '\\n'; // Description of the Service\n\t}\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashwanthkumar%2Fioc-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashwanthkumar%2Fioc-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashwanthkumar%2Fioc-php/lists"}