{"id":13607759,"url":"https://github.com/maglnet/ComposerRequireChecker","last_synced_at":"2025-04-12T14:31:08.131Z","repository":{"id":37706442,"uuid":"46859018","full_name":"maglnet/ComposerRequireChecker","owner":"maglnet","description":"A CLI tool to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies","archived":false,"fork":false,"pushed_at":"2025-04-05T06:58:39.000Z","size":1570,"stargazers_count":939,"open_issues_count":42,"forks_count":71,"subscribers_count":10,"default_branch":"4.17.x","last_synced_at":"2025-04-06T18:01:32.929Z","etag":null,"topics":["ci-tools","code-quality"],"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/maglnet.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":"2015-11-25T12:01:02.000Z","updated_at":"2025-04-05T09:54:22.000Z","dependencies_parsed_at":"2023-12-17T16:27:20.920Z","dependency_job_id":"ba13ecc5-bcbf-4995-8eea-c2738a272658","html_url":"https://github.com/maglnet/ComposerRequireChecker","commit_stats":{"total_commits":544,"total_committers":53,"mean_commits":"10.264150943396226","dds":0.71875,"last_synced_commit":"0c48390ffdddc3e04a5ff015a5db456207a12def"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maglnet%2FComposerRequireChecker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maglnet%2FComposerRequireChecker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maglnet%2FComposerRequireChecker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maglnet%2FComposerRequireChecker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maglnet","download_url":"https://codeload.github.com/maglnet/ComposerRequireChecker/tar.gz/refs/heads/4.17.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581084,"owners_count":21128099,"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":["ci-tools","code-quality"],"created_at":"2024-08-01T19:01:21.327Z","updated_at":"2025-04-12T14:31:07.759Z","avatar_url":"https://github.com/maglnet.png","language":"PHP","funding_links":[],"categories":["Table of Contents","PHP","目录","Testing","Tools","Ecosystem"],"sub_categories":["Dependency Management Extras","依赖关系管理临时演员 dependency-management-extras","Checking dependencies","Support","Dependency Management"],"readme":"# ComposerRequireChecker\n\nA CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package.\nThis will prevent you from using \"soft\" dependencies that are not defined within your `composer.json` require section.\n\n[![current version](https://img.shields.io/packagist/v/maglnet/composer-require-checker.svg?style=flat-square)](https://packagist.org/packages/maglnet/composer-require-checker)\n\n## What's it about?\n\n\"Soft\" (or transitive) dependencies are code that you did not explicitly define to be there but use it nonetheless. The opposite is a \"hard\" (or direct) dependency.\n\nYour code most certainly uses external dependencies. Imagine that you found a library to access a remote API. You require `thatvendor/api-lib` for your software and use it in your code. This library is a hard dependency.\n\nThen you see that another remote API is available, but no library exists. The use case is simple, so you look around and find that `guzzlehttp/guzzle` (or any other HTTP client library) is already installed, and you use it right away to fetch some info. Guzzle just became a soft dependency.\n\nThen someday, when you update your dependencies, your access to the second API breaks. Why? Turns out that the reason `guzzlehttp/guzzle` was installed is that it is a dependency of `thatvendor/api-lib` you included, and their developers decided to update from an earlier major version to the latest and greatest, simply stating in their changelog: \"Version 3.1.0 uses the latest major version of Guzzle - no breaking changes expected.\"\n\nAnd you think: What about my broken code?\n\nComposerRequireChecker parses your code and your composer.json-file to see whether your code uses symbols that are not declared as a required library, i.e. that are soft dependencies. If you rely on components that are already installed but didn't explicitly request them, this tool will complain about them and you should require them explicitly, making them hard dependencies. This will prevent unexpected updates.\n\nIn the situation above you wouldn't get the latest update of `thatvendor/api-lib`, but your code would continue to work if you also required `guzzlehttp/guzzle` before the update.\n\nThe tool will also check for usage of PHP functions that are only available if an extension is installed, and will complain if that extension isn't explicitly required.\n\n## Installation / Usage\n\nComposerRequireChecker is not supposed to be installed as part of your project dependencies.\n\n### PHAR file [preferred]\n\nPlease check the [releases](https://github.com/maglnet/ComposerRequireChecker/releases) for available PHAR files.\n[Download the latest release](https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar) and run it like this:\n```\nphp composer-require-checker.phar check /path/to/your/project/composer.json\n```\n\n### PHIVE\n\nIf you already use [PHIVE](https://phar.io/)  to install and manage your project’s tooling, then you should be able to simply install ComposerRequireChecker like this:\n\n```\nphive install composer-require-checker\n``` \n\n### Composer - global command\n\nThis package can be easily globally installed by using [Composer]:\n\n```sh\ncomposer global require maglnet/composer-require-checker\n```\n\nIf you haven't already setup your composer installation to support global requirements, please refer to the [Composer CLI - global]\nIf this is already done, run it like this:\n\n```\ncomposer-require-checker check composer.json\n```\n\nThe `composer.json` here refers to the root Composer manifest of your project.\n\n### A note about Xdebug\n\nIf your PHP is including Xdebug when running ComposerRequireChecker, you may experience additional issues like exceeding the Xdebug-related max-nesting-level - and on top, Xdebug slows PHP down.\n\nIt is recommended to run ComposerRequireChecker without Xdebug. \n\nIf you cannot provide a PHP instance without Xdebug yourself, try setting an environment variable like this for just the command: `XDEBUG_MODE=off php composer-require-checker`.\n\n## Configuration\n\nComposerRequireChecker is configured to whitelist some symbols per default. Have a look at the\n[config file example](data/config.dist.json) to see which configuration options are available.\n\nYou can now adjust this file, as needed, and tell composer-require-checker to use it for its configuration. \nIf you want to use the default whitelist, you may remove this section and only adjust the sections you would like to change.\n\nNote that if you want to add something on top of a section, you'll have to copy the whole section's content. \nThis tool intentionally only reads one configuration file. If you pass only your new settings, you'll get error reports about the PHP core\nextensions and internal symbols like `true` or `false` being undefined.\n\n```sh\nbin/composer-require-checker check --config-file=path/to/config.json /path/to/your/project/composer.json\n``` \n\nBy default, it uses `composer-require-checker.json` if the file exists. \n\n### Scan Additional Files\n\nTo scan files, that are not part of your autoload definition you may add glob patterns to the config file's `scan-files`\nsection.\n\nThe following example configuration file would also scan the file `bin/console` and all files with `.php` extension within your `bin/` folder:\n\n`composer-require-checker.json`:\n```json\n{\n    \"scan-files\" : [\"bin/console\", \"bin/*.php\"]\n}\n```\n\nIf you don't like copying the tool's default settings, consider adding these paths to the Composer autoloading section \nof your project instead.\n\n## Usage\n\nComposerRequireChecker runs on an existing directory structure. It does not change your code and does not even install your composer dependencies. That is a task that is entirely up to you, allowing you to change/improve things after a scan to see if it fixes the issue.\n\nSo the usual workflow would be\n\n1. Clone your repo\n2. `composer install` your dependencies\n3. `composer-require-checker check` your code\n\n### Dealing with custom installer plugins\n\nComposerRequireChecker only fetches its knowledge of where files are from your project's `composer.json`. It does not use Composer itself to understand custom directory structures.\n\nIf your project requires making use of any install plugins to put files in directories that are not `vendor/` or defined via the `vendor-dir` config setting in `composer.json`, ComposerRequireChecker will fail to detect the required code correctly.\n\nAs a workaround, you can install your dependencies without plugins just for the scan:\n\n1. Clone your repo\n2. `composer install --no-plugins` will put all code into the `vendor` folder\n3. `composer-require-checker check` your code\n4. `composer install` dependencies once again in the correct location\n\n## License\n\nThis package is made available under the [MIT LICENSE](LICENSE).\n\n## Credits\n\nThis package was initially designed by [Marco Pivetta](https://github.com/ocramius) and [Matthias Glaub](https://github.com/maglnet).  \nAnd of course all [Contributors](https://github.com/maglnet/ComposerRequireChecker/graphs/contributors).\n\n[Composer]: https://getcomposer.org\n[Composer CLI - global]: https://getcomposer.org/doc/03-cli.md#global\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaglnet%2FComposerRequireChecker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaglnet%2FComposerRequireChecker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaglnet%2FComposerRequireChecker/lists"}