{"id":13622146,"url":"https://github.com/dereuromark/composer-prefer-lowest","last_synced_at":"2025-10-23T23:37:03.349Z","repository":{"id":46186872,"uuid":"163982373","full_name":"dereuromark/composer-prefer-lowest","owner":"dereuromark","description":"Checks prefer-lowest installation for actually defined min versions in composer.json","archived":false,"fork":false,"pushed_at":"2023-11-04T02:35:15.000Z","size":61,"stargazers_count":20,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-27T07:42:56.774Z","etag":null,"topics":["composer","composer-scripts","composer-support","php"],"latest_commit_sha":null,"homepage":"","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/dereuromark.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":"2019-01-03T14:20:09.000Z","updated_at":"2024-04-26T16:47:12.000Z","dependencies_parsed_at":"2022-08-29T05:31:05.972Z","dependency_job_id":"823b6077-70d6-4f5e-9e65-8b6f5b2b7556","html_url":"https://github.com/dereuromark/composer-prefer-lowest","commit_stats":{"total_commits":55,"total_committers":3,"mean_commits":"18.333333333333332","dds":0.509090909090909,"last_synced_commit":"86dc92443a13b423ce632bff0d5e7ffd2aa0f1e6"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2Fcomposer-prefer-lowest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2Fcomposer-prefer-lowest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2Fcomposer-prefer-lowest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2Fcomposer-prefer-lowest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dereuromark","download_url":"https://codeload.github.com/dereuromark/composer-prefer-lowest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814895,"owners_count":20352036,"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":["composer","composer-scripts","composer-support","php"],"created_at":"2024-08-01T21:01:14.805Z","updated_at":"2025-10-23T23:37:03.237Z","avatar_url":"https://github.com/dereuromark.png","language":"PHP","funding_links":[],"categories":["Tools","Table of Contents","Ecosystem"],"sub_categories":["Support","Dependency Management Extras","Dependency Management"],"readme":"# Composer Prefer Lowest Validator\n[![CI](https://github.com/dereuromark/composer-prefer-lowest/actions/workflows/ci.yml/badge.svg)](https://github.com/dereuromark/composer-prefer-lowest/actions/workflows/ci.yml)\n[![Latest Stable Version](https://poser.pugx.org/dereuromark/composer-prefer-lowest/v/stable.svg)](https://packagist.org/packages/dereuromark/composer-prefer-lowest)\n[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg)](https://php.net/)\n[![License](https://poser.pugx.org/dereuromark/composer-prefer-lowest/license.svg)](https://packagist.org/packages/dereuromark/composer-prefer-lowest)\n[![Coding Standards](https://img.shields.io/badge/cs-PSR--2--R-yellow.svg)](https://github.com/php-fig-rectified/fig-rectified-standards)\n[![Total Downloads](https://poser.pugx.org/dereuromark/composer-prefer-lowest/d/total.svg)](https://packagist.org/packages/dereuromark/composer-prefer-lowest)\n\nThis validator will strictly compare the specified minimum versions of your composer.json with the ones actually used by the `prefer-lowest` composer update command option.\n\nThis is useful for all libraries that want to make sure\n- **the defined minimum of each dependency is actually still being tested**\n- no silent regressions (like using too new methods of depending libraries) sneaked in\n\nFor details, see [Why and when is this useful?](https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest).\nThis has been built after Composer didn't have the [motivation](https://github.com/composer/composer/issues/7849) for it.\n\n**A total must-have** for\n- frameworks\n- framework plugins/addons (and testing against the framework minors)\n- custom libraries to be used by apps/projects which have at least one dependency to other libraries\n\nIt is somewhat important for the involved packages to follow semver here. Otherwise some of the comparison might be problematic.\n\nThis is not so useful for projects, as here there is no need to test against anything than latest versions already in use.\nAlso, if your library has no dependencies, you can skip prefer-lowest checks as well as this validation.\n\n## Local Test-Run\nYou want to give it a quick test-spin for one of your libraries? See what results it yields?\n```\ncomposer update --prefer-lowest --prefer-dist --prefer-stable\ncomposer require --dev --update-with-all-dependencies dereuromark/composer-prefer-lowest\nvendor/bin/validate-prefer-lowest\n```\nIf there is no output, that's good. `echo $?` should return `0` (success).\n\n## CI Installation\nIt is recommended to run only for CI and `composer update --prefer-lowest`.\nAs such, it suffices to add it conditionally here.\n\nE.g. for Travis CI:\n```\nphp:\n  - 7.3\n  - 8.1\n\nenv:\n  global:\n    - DEFAULT=1\n\nmatrix:\n  include:\n    - php: 7.3\n      env: PREFER_LOWEST=1\n\nbefore_script:\n  - if [[ $PREFER_LOWEST != 1 ]]; then composer install --prefer-source --no-interaction; fi\n  - if [[ $PREFER_LOWEST == 1 ]]; then composer update --prefer-lowest --prefer-dist --prefer-stable --no-interaction; fi\n  - if [[ $PREFER_LOWEST == 1 ]]; then composer require --dev dereuromark/composer-prefer-lowest; fi\n\nscript:\n  - if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi\n  - if [[ $PREFER_LOWEST == 1 ]]; then vendor/bin/validate-prefer-lowest; fi\n```\n\nYou can, of course, also directly include it into `require-dev`.\nAfter manually running `composer update --prefer-lowest` locally, you can also test this on your local computer then:\n```\nvendor/bin/validate-prefer-lowest\n```\n\nIt returns the list of errors and exits with error code `1` if any violations are found.\nOtherwise it returns with success code `0`.\n\n### Prefer stable\nUsually `composer update --prefer-lowest` suffices.\nMake sure you have `\"prefer-stable\": true` in your composer.json for this to work.\nOtherwise you might have to use the longer version as outlined above.\n\nIn general it is best to just use all flags for your CI script:\n```\ncomposer update --prefer-lowest --prefer-dist --prefer-stable --no-interaction\n```\n\n### Majors only\nIf you want to only error the CI build for major constraint issues, use `--majors-only`/`-m` option:\n```\nvendor/bin/validate-prefer-lowest -m\n```\nThe patch and minor issues will then be warnings only.\n\n### Display only\nIf you want to just display the result in your CI report without failing the build, you could do:\n```\nvendor/bin/validate-prefer-lowest || true\n```\n\n### PHP version\nIn general: Use the minimum PHP version for `prefer-lowest` as defined in your composer.json.\n\nThis tool requires minimum **PHP 7.3**, as such make sure your library to test also runs on this (or higher) for the `prefer-lowest` CI job.\nAt this point, with it being EOL already, you can and should not use any PHP version below 7.3 anyway, or provide support for it.\n\nIt is advised to also raise your composer.json entry for the min PHP version here. Use 7.3 or higher:\n```\n    \"require\": {\n        \"php\": \"\u003e=7.3\",\n```\n\n## Local Composer Script Installation\nFor local testing, when you do not want to modify your composer.json file, you can simple add this composer script:\n```\n\"scripts\": {\n    ...\n    \"lowest\": \" validate-prefer-lowest\",\n    \"lowest-setup\": \"composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction \u0026\u0026 cp composer.json composer.backup \u0026\u0026 composer require --dev --update-with-all-dependencies dereuromark/composer-prefer-lowest \u0026\u0026 mv composer.backup composer.json\",\n```\n\nThen run `composer lowest-setup` to set up the script and finally `composer lowest` to execute.\n\n## TODOs\n- Better version handling, especially around special cases like suffixes.\n\nHelp is greatly appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdereuromark%2Fcomposer-prefer-lowest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdereuromark%2Fcomposer-prefer-lowest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdereuromark%2Fcomposer-prefer-lowest/lists"}