{"id":16372299,"url":"https://github.com/meadsteve/container","last_synced_at":"2025-07-21T03:03:00.558Z","repository":{"id":6656118,"uuid":"7900627","full_name":"meadsteve/Container","owner":"meadsteve","description":"Very basic dependency injection container","archived":false,"fork":false,"pushed_at":"2013-12-19T16:52:49.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-14T17:50:26.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/meadsteve.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":"2013-01-29T20:37:53.000Z","updated_at":"2013-12-19T16:52:50.000Z","dependencies_parsed_at":"2022-08-22T13:31:11.953Z","dependency_job_id":null,"html_url":"https://github.com/meadsteve/Container","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/meadsteve/Container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2FContainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2FContainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2FContainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2FContainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meadsteve","download_url":"https://codeload.github.com/meadsteve/Container/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meadsteve%2FContainer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266231762,"owners_count":23896473,"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-10-11T03:11:01.555Z","updated_at":"2025-07-21T03:03:00.538Z","avatar_url":"https://github.com/meadsteve.png","language":"PHP","readme":"Container\n=========\n\nVery basic dependency injection container.\n\nBuild status\n------------\n\n| branch | status |\n| ------ | ------ |\n| master | [![Build Status](https://travis-ci.org/meadsteve/Container.png?branch=master)](https://travis-ci.org/meadsteve/Container) |\n\nExample Usage\n=========\n\nSetup a resource in the container:\n\n```php\nuse \\Meadsteve\\Container\\Container;\nuse \\Meadsteve\\Container\\Singleton;\n\n$MyContainer = new Container();\n\n$MyContainer-\u003eDependancyOne = new Dependancy();\n$MyContainer-\u003eMyObject = function(Container $Container) {\n\treturn new MyObject($Container-\u003eDependancyOne);\n};\n```\nThen when you need an instance of MyObject:\n\n```php\n$InstanceOfMyObject = $MyContainer-\u003eMyObject;\n```\n\nFor some heavy objects you may not want to run the construction logic each time. Then you may want to use the singleton pattern. This is possible with the provided class:\n\n```php\n$MyContainer-\u003eDBUser = \"DBGuy\";\n$MyContainer-\u003ePassword = \"SuperSecret10\";\n$MyContainer-\u003eDBBasedObject = new Singleton(function(Container $Container) {\n\treturn new DBObject($Container-\u003eDBUser, $Container-\u003ePassword);\n});\n```\n\nWhich is then retrieved in exactly the same way:\n```php\n$DBInstance = $MyContainer-\u003eDBBasedObject\n```\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeadsteve%2Fcontainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeadsteve%2Fcontainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeadsteve%2Fcontainer/lists"}