0

Is there a possibility to let composer install a package only when the PHP version is below a given version.

https://github.com/ircmaxell/password_compat

"ircmaxell/password-compat": "dev-master"

I have found this package to be useful because I have a webserver which runs on PHP 5.4 and I need the password_* functions which are only available >= PHP 5.5.

1 Answer 1

1

Yes, there is. You can find the details on the packagist website, but basically, the package/dependency should be defined with this requirement:

{
    "name": "ircmaxell/password-compat",
    "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
    "require": {
        "php": "<5.5.*",
        "phpunit/phpunit": "4.*"
    }
}

As you can see, I've added "php": "<5.5.*" to the requirements for the package. You can add this requirement to your own composer.json file, by adding the dependency to your repositories array in the composer.json file, and add the requirements there:

{
    "repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/ircmaxell/password_compat",
        "require": {
            "php": "<5.5.*",
        }
    }]
}

Something like that, I only have php5.5 installed, so I was unable to test this, though... but read through the documentation, I'm pretty sure it's possible.

Sign up to request clarification or add additional context in comments.

2 Comments

@Ellias Van Ootegem Shouldn't the requirement for this package be: php: <=5.5?
@stixx: You're right, except then that it should be "php": "<5.5.*", as 5.5 is fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.