{"id":18929525,"url":"https://github.com/thecodingmachine/container-discovery","last_synced_at":"2026-03-16T15:30:17.937Z","repository":{"id":57067861,"uuid":"47134469","full_name":"thecodingmachine/container-discovery","owner":"thecodingmachine","description":"Allowing discovery of container objects through Puli","archived":false,"fork":false,"pushed_at":"2015-11-30T17:25:02.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-16T12:30:25.910Z","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/thecodingmachine.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}},"created_at":"2015-11-30T17:24:33.000Z","updated_at":"2015-12-05T20:00:20.000Z","dependencies_parsed_at":"2022-08-24T10:20:15.668Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/container-discovery","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/thecodingmachine%2Fcontainer-discovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcontainer-discovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcontainer-discovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fcontainer-discovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/container-discovery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239927825,"owners_count":19719835,"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-08T11:33:24.683Z","updated_at":"2026-03-16T15:30:17.878Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Containers discovery for *container-interop*\n\nThis package contains an interface and Puli binding-types to automatically discover containers.\n\n## Introduction\n\n*container-interop* defines a common interface for Container objects (the `ContainerInterface`).\nThis package proposes a default interface for factories that can generate container objects.\n  \nThis factory is static and can be automatically detected by Puli using class discovery.\n\nThe goal is to allow a composite container to automatically detect and create container instances.\n\n## Installation\n\n```\ncomposer require thecodingmachine/container-discovery@dev\n```\n\nThis package adheres to the [SemVer](http://semver.org/) specification and will be fully backward compatible between minor versions.\n\n## Containers discovery\n\nThe goal of this package is to enable a package to automatically publish or discover **containers**.\n\nTo automatically provide a *container* to your application, we use [Puli's discovery mechanism](http://docs.puli.io/en/latest/discovery/introduction.html).\n\nThis package contains a Puli **binding-type** named `container-interop/ContainerFactories`.\nThis binding-type should contain fully qualified class names implementing the `ContainerFactoryInterface` interface.\n\n## Providing containers\n\nTo provide a container, write a `ContainerFactory` that will return an instance of your container implementing \n`ContainerInterface`.\n\nFor instance (using [Picotainer](https://github.com/mouf/picotainer)):\n\n```php\nnamespace My\\Package;\n\nuse Interop\\Container\\Factory\\ContainerFactoryInterface;\nuse Assembly\\ArrayDefinitionProvider;\n\nclass MyContainerFactory implements ContainerFactoryInterface {\n    public static function buildContainer(ContainerInterface $rootContainer, Discovery $discovery) {\n        return new Picotainer([\n            'logger' =\u003e function() {\n                new MyLogger();\n            },\n            $rootContainer\n        ]);    \n    }\n}\n```\n\nOnce your class is written, use Puli to bind it to the list of available containers:\n\n```sh\n$ puli bind \"My\\\\Package\\\\MyContainerFactory\" container-interop/ContainerFactories\n```\n\nNote: by convention, you can add a \"priority\" parameter to the binding. Default priority is 0. Lower priorities \nare processed first (and therefore, higher priorities are overloading lower priorities).\n\n```sh\n$ puli bind \"My\\\\Package\\\\MyContainerFactory\" container-interop/ContainerFactories --param priority=42\n```\n\n\n## Consuming containers\n\nIn your code, you can find all classes of the `container-interop/ContainerFactories` binding-type using:\n\n```php\n// $discovery is the Puli Discovery object.\n\n$factories = $discovery-\u003efindByType('container-interop/ContainerFactories');\n\n// TODO: sample code to sort by priority.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fcontainer-discovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fcontainer-discovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fcontainer-discovery/lists"}