{"id":18929659,"url":"https://github.com/thecodingmachine/root-container","last_synced_at":"2025-10-09T15:36:20.499Z","repository":{"id":25905248,"uuid":"29345951","full_name":"thecodingmachine/root-container","owner":"thecodingmachine","description":"This package contains a facade container that aggregates all containers that have been detected thanks to the mouf/container-installer package.","archived":false,"fork":false,"pushed_at":"2015-02-09T16:52:05.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":16,"default_branch":"1.0","last_synced_at":"2025-10-09T15:36:19.736Z","etag":null,"topics":[],"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/thecodingmachine.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":"2015-01-16T11:34:35.000Z","updated_at":"2015-11-16T20:18:31.000Z","dependencies_parsed_at":"2022-08-22T20:31:14.968Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/root-container","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/root-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Froot-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Froot-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Froot-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Froot-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/root-container/tar.gz/refs/heads/1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Froot-container/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001646,"owners_count":26083147,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08T11:34:13.624Z","updated_at":"2025-10-09T15:36:20.477Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"About RootContainer\n===================\n\nRootContainer is a *facade* for a composite container that aggregates all DI containers detected in the application.\n\nThe big picture\n---------------\n\nThe ultimate goal is to allow the application developer to easily create a \"root container\", \nthat can automatically detect and add containers contained in other packages into a global \ncomposite container that can be used by the application.\n\nCompared to the classical way of thinking about a web application, this is a paradigm shift.\n\n**In a \"classical\" application**, packages added to the application may add new instances to the main and only DI container.\nThis is what SF2 bundles, ZF2 modules or Mouf2 packages are doing.\n\n**Using this approach**, each package provides its own DI container that contains instances. DI containers are added\nto a global container that is queried.\n\nAbout this package\n------------------\n\nDetection of other containers is done using the [Container-Installer](http://mouf-php.com/packages/mouf/container-installer)\ncomponent.\n\nThis package is using detected packages and aggregate those into a unique composite container. This container\nis exposed as a facade.\n\nSo basically, using **RootContainer**, you can access ANY instance of ANY container of your application using:\n\n```php\n$instance = RootContainer::get(\"instance_name\");\n``` \n\nIn the background, `RootContainer` will load the `containers.php` file generated by \n[Container-Installer](http://mouf-php.com/packages/mouf/container-installer) and instanciate all the containers\nof the application.\n\nA word of caution\n-----------------\n\nHaving an easy to use facade for containers does not allow you to use it all over the place :)\nOtherwise, you would be using the RootContainer as a service locator, which is considered by most people to \nbe a bad practice (tip: the author of RootContainer thinks it is a bad practice too).\n\nSo in a perfect world, the RootContainer should be used once or twice in your application, maybe by the\nMVC framework you are using, to fetch the controller, and that's it.\n\nThat being said, it's always useful to be able to access an instance quickly for testing purposes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Froot-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Froot-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Froot-container/lists"}