{"id":18929731,"url":"https://github.com/thecodingmachine/harmony-module-interface","last_synced_at":"2026-03-16T16:30:18.449Z","repository":{"id":30706636,"uuid":"34262711","full_name":"thecodingmachine/harmony-module-interface","owner":"thecodingmachine","description":"The harmony-module-interface package contains interfaces to improve the integration of your project with Harmony.","archived":false,"fork":false,"pushed_at":"2015-07-15T10:49:33.000Z","size":136,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"1.0","last_synced_at":"2025-02-16T12:30:27.145Z","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/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-04-20T13:40:32.000Z","updated_at":"2015-04-21T09:35:05.000Z","dependencies_parsed_at":"2022-08-07T15:16:56.348Z","dependency_job_id":null,"html_url":"https://github.com/thecodingmachine/harmony-module-interface","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%2Fharmony-module-interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fharmony-module-interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fharmony-module-interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2Fharmony-module-interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/harmony-module-interface/tar.gz/refs/heads/1.0","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:47.580Z","updated_at":"2026-03-16T16:30:18.385Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Harmony module interface\n========================\n\nOut of the box, Harmony is a nice UI interface to help you with your PHP projects. However, it does not bring\nmany features. In order to be completely useful, it should be able to analyze your project, and even better,\nit should be able to detect DI containers (or service locators, ...) and inspect them.\n\nFor this to be possible, Harmony relies on modules. There are already modules existing for a set of\nframeworks, and luckily, it is quite easy to write one.\n\nRegistering an Harmony module\n-----------------------------\n\nHarmony modules are registered in a `modules.php` file.\nThis file is a simple PHP file that returns an array of modules.\n\n**modules.php**\n```php\n\u003c?php\nreturn [\n    new MyHarmonyModule();\n];\n```\n\nwhere `MyHarmonyModule` is a module depending on the framework you are using.\n\nWriting an Harmony module\n-------------------------\n\nModules should implement this simple interfaces:\n\n**HarmonyModuleInterface**\n```php\n/**\n * Classes implementing this interface represent modules that can be used by Harmony.\n */\ninterface HarmonyModuleInterface\n{\n    /**\n     * You can return a container if the module provides one.\n     *\n     * It will be chained to the application's root container.\n     *\n     * @param ContainerInterface $rootContainer\n     * @return ContainerInterface|null\n     */\n    public function getContainer(ContainerInterface $rootContainer);\n\n    /**\n     * Returns a class that can be used to explore a container\n     *\n     * @return ContainerExplorerInterface|null\n     */\n    public function getContainerExplorer();\n}\n```\n\nThe Harmony module interface expects containers to be respecting [container-interop's `ContainerInterface`](https://github.com/container-interop/container-interop).\n\nAn important part of the interface is that it should offer a way to **explore** the container of your application.\nThis is represented by the `getContainerExplorer` method that should return an\nobject implementing `ContainerExplorerInterface`.\n\n**ContainerExplorerInterface**\n```php\ninterface ContainerExplorerInterface\n{\n    /**\n     * Returns the name of the instances implementing `$type`\n     *\n     * @param string $type A fully qualified class or interface name\n     * @return string[]\n     */\n    public function getInstancesByType($type);\n    \n    /**\n     * Returns the name of the instances whose tag is `$tag`\n     *\n     * @param string $tag The tag to retrieve\n     * @return string[]\n     */\n    public function getInstancesByTag($tag);\n}\n```\n\nNote: some containers cannot be searched by type. Other containers do not have a \"tag\" mechanism. If your container does not\nsupport this feature, the matching function should return an empty array.\n\nIf you are writing a package that contains an Harmony module, you should include this package into your Composer dependencies:\n\n**composer.json**\n```\n{\n  \"require\": {\n    \"harmony/harmony-module-interface\": \"~1.0\"\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fharmony-module-interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fharmony-module-interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fharmony-module-interface/lists"}