{"id":20900552,"url":"https://github.com/phpbench/container","last_synced_at":"2025-05-13T01:32:27.847Z","repository":{"id":6886711,"uuid":"55606670","full_name":"phpbench/container","owner":"phpbench","description":"Simple, extensible and configurable dependency injection container.","archived":false,"fork":false,"pushed_at":"2023-10-30T13:41:02.000Z","size":27,"stargazers_count":15,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-25T15:58:59.863Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phpbench.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}},"created_at":"2016-04-06T13:07:18.000Z","updated_at":"2024-01-30T10:33:06.000Z","dependencies_parsed_at":"2024-06-18T16:48:56.275Z","dependency_job_id":"ecabe778-8bf7-4818-8693-a41381f5cc5b","html_url":"https://github.com/phpbench/container","commit_stats":{"total_commits":21,"total_committers":7,"mean_commits":3.0,"dds":"0.33333333333333337","last_synced_commit":"a59b929e00b87b532ca6d0edd8eca0967655af33"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpbench%2Fcontainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpbench%2Fcontainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpbench%2Fcontainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpbench%2Fcontainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpbench","download_url":"https://codeload.github.com/phpbench/container/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253854090,"owners_count":21974221,"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-18T11:20:40.824Z","updated_at":"2025-05-13T01:32:27.614Z","avatar_url":"https://github.com/phpbench.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHPBench Service Container\n==========================\n\n[![Build Status](https://travis-ci.org/phpbench/container.svg?branch=master)](https://travis-ci.org/phpbench/container)\n\nSimple, extensible dependency injection container with parameters and service\ntagging. Implements [container\ninterop](https://github.com/container-interop/container-interop).\n\nSimple usage\n------------\n\n```php\n$container = new Container();\n$container-\u003eregister('foobar', function (Container $container) {\n    return new \\stdClass();\n});\n```\n\nExtending and Tagging\n---------------------\n\nExtension classes should be passed as the first argument to the container (the\nuser configuration is the second argumnet).\n\n```php\n$container = new Container(\n    [\n        MyExtension::class\n    ],\n    [\n        'foo.bar' =\u003e 'my_new_value',\n    ]\n);\n$container-\u003einit(); // will trigger loading of the extensions.\n```\n\n```php\nclass MyExtension implements ExtensionInterface\n{\n    public function load(Container $container)\n    {\n        $container-\u003eregister('my_service', function (Container $container) {\n            $service = new MyService(\n                $container-\u003egetParameter('foo_bar'),\n                $container-\u003eget('some_other_service')\n            );\n\n            foreach ($container-\u003egetServiceIdsForTag('tag') as $serviceId =\u003e $params) {\n                $service-\u003eadd($container-\u003eget($serviceId));\n            }\n\n            return $service;\n        });\n\n        $container-\u003eregister('tagged_service', function (Container $container) {\n            return new MyService(\n                $container-\u003egetParameter('foo_bar'),\n                $container-\u003eget('some_other_service')\n            );\n        }, [ 'tag' =\u003e [ 'param1' =\u003e 'foobar' ]);\n    }\n\n    /**\n     * Return the default parameters for the container.\n     *\n     * @return array\n     */\n    public function getDefaultConfig()\n    {\n        return [\n            'foo_bar' =\u003e 'this is foo'\n        ];\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpbench%2Fcontainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpbench%2Fcontainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpbench%2Fcontainer/lists"}