Skip to content

typisttech/php-matrix

Repository files navigation

PHP Matrix

GitHub Release Test codecov License Follow @TangRufus on X Follow @TangRufus.com on Bluesky Sponsor @TangRufus via GitHub Hire Typist Tech

List PHP versions that satisfy the given constraint.

Built with ♥ by Typist Tech


Tip

Hire Tang Rufus!

I am looking for my next role, freelance or full-time. If you find this tool useful, I can build you more weird stuffs like this. Let's talk if you are hiring PHP / Ruby / Go developers.

Contact me at https://typist.tech/contact/


Usage

List PHP versions that satisfy the required PHP constraint in composer.json

$ cat ./composer.json
{"require":{"php":"^7 || ^8"}}

$ php-matrix composer
{
    "constraint": "^7 || ^8",
    "versions": [
        "7.0",
        "7.1",
        "7.2",
        "7.3",
        "7.4",
        "8.0",
        "8.1",
        "8.2",
        "8.3",
        "8.4"
    ],
    "lowest": "7.0",
    "highest": "8.4"
}
$ cat ./some/path/to/the.json
{"require":{"php":"~7.4.29 || ~8.1.29"}}

$ php-matrix composer --source=php.net --mode=full ./some/path/to/the.json
{
    "constraint": "~7.4.29 || ~8.1.29",
    "versions": [
        "7.4.29",
        "7.4.30",
        "7.4.32",
        "7.4.33",
        "8.1.29",
        "8.1.30",
        "8.1.31",
        "8.1.32",
        "8.1.33"
    ],
    "lowest": "7.4.29",
    "highest": "8.1.33"
}
$ php-matrix composer --help
Description:
  List PHP versions that satisfy the required PHP constraint in composer.json

Usage:
  composer [options] [--] [<path>]

Arguments:
  path                  Path to composer.json file. [default: "./composer.json"]

Options:
      --source=SOURCE   Available sources:
                        - auto: Use offline in minor-only mode. Otherwise, fetch from php.net
                        - php.net: Fetch releases information from php.net
                        - offline: Use hardcoded releases information
                         [default: "auto"]
      --mode=MODE       Available modes:
                        - full: Report all satisfying versions in MAJOR.MINOR.PATCH format
                        - minor-only: Report MAJOR.MINOR versions only
                         [default: "minor-only"]
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

List PHP versions that satisfy the given constraint

$ php-matrix constraint '^7 || ^8'
{
    "constraint": "^7 || ^8",
    "versions": [
        "7.0",
        "7.1",
        "7.2",
        "7.3",
        "7.4",
        "8.0",
        "8.1",
        "8.2",
        "8.3",
        "8.4"
    ],
    "lowest": "7.0",
    "highest": "8.4"
}
$ php-matrix constraint --source=php.net --mode=full '~7.4.29 || ~8.1.29'
{
    "constraint": "~7.4.29 || ~8.1.29",
    "versions": [
        "7.4.29",
        "7.4.30",
        "7.4.32",
        "7.4.33",
        "8.1.29",
        "8.1.30",
        "8.1.31",
        "8.1.32",
        "8.1.33"
    ],
    "lowest": "7.4.29",
    "highest": "8.1.33"
}
$ php-matrix constraint --help
Description:
  List PHP versions that satisfy the given constraint

Usage:
  constraint [options] [--] <constraint>

Arguments:
  constraint            The version constraint.

Options:
      --source=SOURCE   Available sources:
                        - auto: Use offline in minor-only mode. Otherwise, fetch from php.net
                        - php.net: Fetch releases information from php.net
                        - offline: Use hardcoded releases information
                         [default: "auto"]
      --mode=MODE       Available modes:
                        - full: Report all satisfying versions in MAJOR.MINOR.PATCH format
                        - minor-only: Report MAJOR.MINOR versions only
                         [default: "minor-only"]
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Options

--mode

Available modes:

  • minor-only (default): Report MAJOR.MINOR versions only
  • full: Report all satisfying versions in MAJOR.MINOR.PATCH format

--source

Available sources:

  • auto (default): Use offline in minor-only mode. Otherwise, fetch from php.net
  • php.net: Fetch releases information from php.net
  • offline: Use hardcoded releases information

Tip

Hire Tang Rufus!

There is no need to understand any of these quirks. Let me handle them for you. I am seeking my next job, freelance or full-time.

If you are hiring PHP / Ruby / Go developers, contact me at https://typist.tech/contact/

Installation

Homebrew (macOS / Linux) (Recommended)

brew tap typisttech/tap
brew install typisttech/tap/php-matrix

apt-get (Debian based distributions, for example: Ubuntu)

curl -1sLf 'https://dl.cloudsmith.io/public/typisttech/oss/setup.deb.sh' | sudo -E bash
sudo apt-get install php-matrix

Instead of the automatic setup script, you can manually configure the repository with the instructions on Cloudsmith.

Manual .deb (Debian based distributions, for example: Ubuntu)

Warning

If you install the .deb file manually, you have to take care of updating it by yourself.

Download the latest .deb file from GitHub Releases, or via gh:

# Both arm64 (aarch64) and amd64 (x86_64) architectures are available.
gh release download --repo 'typisttech/php-matrix' --pattern 'php-matrix_linux_arm64.deb'

Optionally, verify the .deb file:

gh attestation verify --repo 'typisttech/php-matrix' 'php-matrix_linux_arm64.deb'

Finally, install the package:

sudo dpkg -i php-matrix_linux_arm64.deb

Manual Binary

Warning

If you install the binary manually, you have to take care of updating it by yourself.

Download the latest .tar.gz file from GitHub Releases, or via gh:

# Both darwin (macOS) and linux operating systems are available.
# Both arm64 (aarch64) and amd64 (x86_64) architectures are available.
gh release download --repo 'typisttech/php-matrix' --pattern 'php-matrix_darwin_arm64.tar.gz'

Optionally, verify the .tar.gz file:

gh attestation verify --repo 'typisttech/php-matrix' 'php-matrix_darwin_arm64.tar.gz'

Finally, unarchive and move the binary into $PATH:

tar -xvf 'php-matrix_darwin_arm64.tar.gz'

# Or, move it to any directory under `$PATH`
mv php-matrix /usr/local/bin

Credits

PHP Matrix is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.

Full list of contributors can be found on GitHub.

Copyright and License

This project is a free software distributed under the terms of the MIT license. For the full license, see LICENSE.

Contribute

Feedbacks / bug reports / pull requests are welcome.