All Projects → dereuromark → composer-prefer-lowest

dereuromark / composer-prefer-lowest

Licence: MIT License
Checks prefer-lowest installation for actually defined min versions in composer.json

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to composer-prefer-lowest

requirements
Requirements checker for WordPress plugins
Stars: ✭ 37 (+184.62%)
Mutual labels:  composer
docker-drupal
Docker scaffolding for Drupal 8
Stars: ✭ 41 (+215.38%)
Mutual labels:  composer
is-biz-mail-php
isBizMail tells you whether a given email address belongs to a free email account provider (gmail.com, yahoo.es, yandex.ru etc) or not.
Stars: ✭ 19 (+46.15%)
Mutual labels:  composer
igcreator
Instagram mass account creator with proxies 🔃 and cookies 🍪 support
Stars: ✭ 35 (+169.23%)
Mutual labels:  composer
wpacked
📦 WPacked is a WordPress development starter kit with portability and immediate local development in mind.
Stars: ✭ 73 (+461.54%)
Mutual labels:  composer
xml-lint
A php tool to lint and validate xml files from the commandline.
Stars: ✭ 14 (+7.69%)
Mutual labels:  composer
alfred-packagist
Alfred workflow to search for PHP packages with Packagist
Stars: ✭ 21 (+61.54%)
Mutual labels:  composer
XoopsCore25
XOOPS Core 2.5.x (current release is 2.5.10: https://github.com/XOOPS/XoopsCore25/releases)
Stars: ✭ 50 (+284.62%)
Mutual labels:  composer
composer-wp
Manage WordPress core, plugins, and themes with composer.
Stars: ✭ 16 (+23.08%)
Mutual labels:  composer
php-legal-licenses
A utility to help generate a file containing information about dependencies including the full license text.
Stars: ✭ 62 (+376.92%)
Mutual labels:  composer
cleanmymac
A developer friendly command line cleaner program for modern macOS systems
Stars: ✭ 35 (+169.23%)
Mutual labels:  composer
LaravelFtp
Laravel FTP client
Stars: ✭ 15 (+15.38%)
Mutual labels:  composer
composer-install
A GitHub Action to streamline installation of PHP dependencies with Composer.
Stars: ✭ 151 (+1061.54%)
Mutual labels:  composer
project
🚀 Repo to `composer create project` a Bolt 5 project.
Stars: ✭ 27 (+107.69%)
Mutual labels:  composer
assert-true
A lot of ways to you set your assert as true
Stars: ✭ 19 (+46.15%)
Mutual labels:  composer
apigee-client-php
Client library to make API calls to Apigee Edge Management API
Stars: ✭ 18 (+38.46%)
Mutual labels:  composer
wordpress
The WordPress project layout used by many of Seravo's customers, suitable also for local development with Vagrant and git deployment
Stars: ✭ 95 (+630.77%)
Mutual labels:  composer
docker
docker environment for PHP developers
Stars: ✭ 12 (-7.69%)
Mutual labels:  composer
JakePHP
JakePHP is a boilerplate created for modern web application development on Linux platforms. Simply clone, and start developing!
Stars: ✭ 12 (-7.69%)
Mutual labels:  composer
crook
Simple hook management tool made with PHP
Stars: ✭ 60 (+361.54%)
Mutual labels:  composer

Composer Prefer Lowest Validator

CI Latest Stable Version Minimum PHP Version License Coding Standards Total Downloads

This 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.

This is useful for all libraries that want to make sure

  • the defined minimum of each dependency is actually still being tested
  • no silent regressions (like using too new methods of depending libraries) sneaked in

For details, see Why and when is this useful?. This has been built after Composer didn't have the motivation for it.

A total must-have for

  • frameworks
  • framework plugins/addons (and testing against the framework minors)
  • custom libraries to be used by apps/projects which have at least one dependency to other libraries

It is somewhat important for the involved packages to follow semver here. Otherwise some of the comparison might be problematic.

This is not so useful for projects, as here there is no need to test against anything than latest versions already in use. Also, if your library has no dependencies, you can skip prefer-lowest checks as well as this validation.

Local Test-Run

You want to give it a quick test-spin for one of your libraries? See what results it yields?

composer update --prefer-lowest --prefer-dist --prefer-stable
composer require --dev --update-with-all-dependencies dereuromark/composer-prefer-lowest
vendor/bin/validate-prefer-lowest

If there is no output, that's good. echo $? should return 0 (success).

CI Installation

It is recommended to run only for CI and composer update --prefer-lowest. As such, it suffices to add it conditionally here.

E.g. for Travis CI:

php:
  - 7.3
  - 8.1

env:
  global:
    - DEFAULT=1

matrix:
  include:
    - php: 7.3
      env: PREFER_LOWEST=1

before_script:
  - if [[ $PREFER_LOWEST != 1 ]]; then composer install --prefer-source --no-interaction; fi
  - if [[ $PREFER_LOWEST == 1 ]]; then composer update --prefer-lowest --prefer-dist --prefer-stable --no-interaction; fi
  - if [[ $PREFER_LOWEST == 1 ]]; then composer require --dev dereuromark/composer-prefer-lowest; fi

script:
  - if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi
  - if [[ $PREFER_LOWEST == 1 ]]; then vendor/bin/validate-prefer-lowest; fi

You can, of course, also directly include it into require-dev. After manually running composer update --prefer-lowest locally, you can also test this on your local computer then:

vendor/bin/validate-prefer-lowest

It returns the list of errors and exits with error code 1 if any violations are found. Otherwise it returns with success code 0.

Prefer stable

Usually composer update --prefer-lowest suffices. Make sure you have "prefer-stable": true in your composer.json for this to work. Otherwise you might have to use the longer version as outlined above.

In general it is best to just use all flags for your CI script:

composer update --prefer-lowest --prefer-dist --prefer-stable --no-interaction

Majors only

If you want to only error the CI build for major constraint issues, use --majors-only/-m option:

vendor/bin/validate-prefer-lowest -m

The patch and minor issues will then be warnings only.

Display only

If you want to just display the result in your CI report without failing the build, you could do:

vendor/bin/validate-prefer-lowest || true

PHP version

In general: Use the minimum PHP version for prefer-lowest as defined in your composer.json.

This 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. At 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.

It is advised to also raise your composer.json entry for the min PHP version here. Use 7.3 or higher:

    "require": {
        "php": ">=7.3",

Local Composer Script Installation

For local testing, when you do not want to modify your composer.json file, you can simple add this composer script:

"scripts": {
    ...
    "lowest": " validate-prefer-lowest",
    "lowest-setup": "composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction && cp composer.json composer.backup && composer require --dev --update-with-all-dependencies dereuromark/composer-prefer-lowest && mv composer.backup composer.json",

Then run composer lowest-setup to set up the script and finally composer lowest to execute.

TODOs

  • Better version handling, especially around special cases like suffixes.

Help is greatly appreciated.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].