{"id":18929747,"url":"https://github.com/thecodingmachine/definition-discovery","last_synced_at":"2026-03-16T16:30:18.675Z","repository":{"id":66284942,"uuid":"46990384","full_name":"thecodingmachine/definition-discovery","owner":"thecodingmachine","description":"[EXPERIMENTAL] Allows automatic discovery of definition provider objects","archived":false,"fork":false,"pushed_at":"2015-11-30T14:03:24.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-16T12:30:28.602Z","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-27T16:43:21.000Z","updated_at":"2015-11-27T16:44:45.000Z","dependencies_parsed_at":"2023-03-13T20:30:09.082Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/definition-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%2Fdefinition-discovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fdefinition-discovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fdefinition-discovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fdefinition-discovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/definition-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:34:51.509Z","updated_at":"2026-03-16T16:30:18.643Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Definitions discovery for *definition-interop*\n\nThis package contains an interface and Puli binding-types to automatically discover definition providers.\n\n## Introduction\n\nModules (aka packages or bundles) are widespread in modern frameworks. Unfortunately each framework has its own convention and tools for writing them. The goal of *container-interop* and more specifically [*definition-interop*](https://github.com/container-interop/definition-interop/) is to help developers write modules that can work in any framework.\n\nIn *definition-interop*, definition provider objects (implementing the `DefinitionProviderInterface`) can return sets of\ndefinitions. This package proposes a default interface for factories of definition providers.\n  \nThis factory is static and can be automatically detected by Puli using class discovery.\n\nThe goal is to allow containers to automatically detect and create definition provider instances.\n\n## Installation\n\n```\ncomposer require container-interop/definition-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## Definitions discovery\n\nThe goal of this package is to enable a package to automatically publish or discover **definitions**.\nDefinitions are generated by **definition providers** (implementing the `DefinitionProviderInterface`), so what we\nreally want to do is to get a list of **definition providers**.\n\nTo automatically provide a *definition provider* 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/DefinitionProviderFactories`.\nThis binding-type should contain fully qualified class names implementing the `DefinitionProviderFactoryInterface` interface.\n\n## Providing definition providers\n\nTo provide a definition provider, write a `DefinitionProviderFactory` that will return an instance of your `DefinitionProvider`.\n\nFor instance (using [mnapoli/assembly](https://github.com/mnapoli/assembly)):\n\n```php\nnamespace My\\Package;\n\nuse Interop\\Container\\Definition\\Factory\\DefinitionProviderFactoryInterface;\nuse Assembly\\ArrayDefinitionProvider;\n\nclass MyDefinitionProviderFactory implements DefinitionProviderFactoryInterface {\n    public static function buildDefinitionProvider(Discovery $discovery) {\n        return new ArrayDefinitionProvider([\n            'logger' =\u003e \\Assembly\\instance('MyLogger')\n                -\u003esetConstructorArguments('warning')\n                -\u003eaddMethodCall('setDebug', true),\n        ]);    \n    }\n}\n```\n\nOnce your class is written, use Puli to bind it to the list of available definition providers:\n\n```sh\n$ puli bind \"My\\\\Package\\\\MyDefinitionProviderFactory\" container-interop/DefinitionProviderFactories\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\\\\MyDefinitionProviderFactory\" container-interop/DefinitionProviderFactories --param priority=42\n```\n\n\n## Consuming definition providers\n\nIn your code, you can find all classes of the `container-interop/DefinitionProviderFactories` binding-type using:\n\n```php\nuse Interop\\Container\\Definition\\Factory\\DefinitionProviderFactoryInterface;\n\n// $discovery is the Puli Discovery object.\n\n$factories = $discovery-\u003efindByType('container-interop/DefinitionProviderFactories');\n\n// TODO: sample code to sort by priority.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fdefinition-discovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fdefinition-discovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fdefinition-discovery/lists"}