{"id":22147543,"url":"https://github.com/myerscode/package-discovery","last_synced_at":"2025-07-26T02:31:50.424Z","repository":{"id":57900688,"uuid":"503931846","full_name":"myerscode/package-discovery","owner":"myerscode","description":"A package to help find plugins for packages","archived":false,"fork":false,"pushed_at":"2024-05-16T16:29:28.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-17T05:46:58.842Z","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/myerscode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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":"2022-06-15T21:48:48.000Z","updated_at":"2024-05-16T16:29:32.000Z","dependencies_parsed_at":"2023-01-22T07:02:08.009Z","dependency_job_id":null,"html_url":"https://github.com/myerscode/package-discovery","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fpackage-discovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fpackage-discovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fpackage-discovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Fpackage-discovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myerscode","download_url":"https://codeload.github.com/myerscode/package-discovery/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227246923,"owners_count":17753428,"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-12-01T23:18:19.274Z","updated_at":"2025-07-26T02:31:50.417Z","avatar_url":"https://github.com/myerscode.png","language":"PHP","readme":"# Package Discovery\n\u003e A service to help easily find plugins for your services, using Composer metadata!\n\n[![Latest Stable Version](https://poser.pugx.org/myerscode/package-discovery/v/stable)](https://packagist.org/packages/myerscode/package-discovery)\n[![Total Downloads](https://poser.pugx.org/myerscode/package-discovery/downloads)](https://packagist.org/packages/myerscode/package-discovery)\n[![License](https://poser.pugx.org/myerscode/package-discovery/license)](https://packagist.org/packages/myerscode/package-discovery)\n![Tests](https://github.com/myerscode/package-discovery/actions/workflows/tests.yml/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/myerscode/package-discovery/graph/badge.svg?token=YR0YHVERNV)](https://codecov.io/gh/myerscode/utilities-strings)\n\n\n## Install\n\nYou can install this package via composer:\n\n``` bash\ncomposer require myerscode/package-discovery\n```\n\n## Usage\n\nPublishing projects just need to add appropriate metadata in their package, which can be then detected by a consuming \nproject. A project which wants to disover projects will need to instantiate a `Finder` to look up the project namespace.\nYou will then be able to consume the found metadata in the project as desired.\n\n### Publishing project\n\nIn your `package.json` file, add a object in the `extras` object, with a key that relates to the project namespace you\nwant to discover it.\n\n```json\n{\n  \"name\": \"myerscode/corgis\",\n  \"extra\": {\n    \"myerscode\": {\n      \"corgis\": [\"Gerald\", \"Rupert\"],\n      \"providers\": [\n        \"Myerscode\\\\Corgis\\\\CorgiProvider\"\n      ]\n    }\n  }\n}\n```\n\n### Consuming project\n\nUsing the `Finder` class, initiate passing in the root path, relative to the `vendor` directory.\n\nThen use the `discover` method to find all packages that have the given name in its extras field.\n\n```php\n$finder = new Finder(__DIR__);\n\n// would find all installed packages that have a myerscode namespace in the extras\n$packages = $finder-\u003ediscover('myerscode');\n```\n\nAfter discovering package you would have an array of metadata for each one discovered.\n\n```php\n[\n  \"myerscode/corgis\" =\u003e [\n      \"corgis\": [\"Gerald\", \"Rupert\"],\n      \"providers\": [\n        \"Myerscode\\\\Corgis\\\\CorgiProvider\"\n      ]\n  ]\n]\n```\n\n### Avoiding discovery\n\nIf you don't want to discover a specific project, then you can add some metadata in the consuming package to prevent this.\n\nYou would do this by adding the package name to `avoid` under the projects namespace in the extras field of `package.json`.\n\n```json\n{\n  \"name\": \"myerscode/demo-project\",\n  \"extra\": {\n    \"myerscode\": {\n      \"avoid\": [\n        \"myerscode/corgis\"\n      ]\n    }\n  }\n}\n```\n\nIf you want to avoid loading in all discoverable packages, simply add `*` in the avoid field.\n\n```json\n{\n  \"name\": \"myerscode/demo-project\",\n  \"extra\": {\n    \"myerscode\": {\n      \"avoid\": [ \"*\" ]\n    }\n  }\n}\n```\n\n## Locating a package\n\nWhen you want to find out where a package is located on the disk, you can use the `locate` method to look up its absolute \npath.\n\n```php \n$finder = new Finder(__DIR__);\n\necho $finder-\u003elocate('myerscode/test-package');\n\n// /User/fred/project-name/vendor/myerscode/test-package\n```\n\n## Getting package meta for a service\n\nTo get package meta for a specific service call the `packageMetaForService` method, passing the package name and the service name.\n\n```php \n$finder = new Finder(__DIR__);\n\necho $finder-\u003epackageMetaForService('myerscode/test-package', 'myerscode');\n\n[\n    \"corgis\": [\"Gerald\", \"Rupert\"],\n    \"providers\": [\n        \"Myerscode\\\\Corgis\\\\CorgiProvider\"\n    ]\n]\n```\n\n## Getting package extra\n\nTo get all the extras data for a package call the `packageExtra` method.\n\n```php \n$finder = new Finder(__DIR__);\n\necho $finder-\u003epackageExtra('myerscode/test-package');\n\n[\n    \"myerscode\" =\u003e [\n        \"corgis\": [\"Gerald\", \"Rupert\"],\n        \"providers\": [\n            \"Myerscode\\\\Corgis\\\\CorgiProvider\"\n        ]\n    ]\n]\n```\n\n## Issues\n\nBug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/myerscode/package-discovery/issues).\n\n## Contributing\n\nSee the Myerscode [contributing](https://github.com/myerscode/docs/blob/master/contributing.md) page for information.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Fpackage-discovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyerscode%2Fpackage-discovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Fpackage-discovery/lists"}