Search code examples
phpcomposer-phppackagist

Install one package without checking all requirements with composer


I have a composer.json like this:

{
"require": {
    "symfony/yaml" : "dev-master",
    "symfony/console" : "dev-master",
    "ebuildy/ebuildy" : "dev-master",
    "keboola/php-encryption": "dev-master",
    "pear-pear.php.net/mail_mime" : "*",
    "pear-pear.php.net/http_request2" : "*",
    "pear-pear.php.net/mail_mimedecode" : "*",
    "microsoft/windowsazure": "*",
    "rollbar/rollbar": "dev-master",
    "facebook/php-sdk-v4" : "4.0.*",
    "happyr/linkedin-api-client": "dev-master",
    "zircote/swagger-php" : "dev-master",
    "google/apiclient" : "dev-master"
},
    "autoload": {
        "psr-0": {
           "bizlunch": "src/"
        }
    },
    "minimum-stability": "dev"
}

Just added "google/apiclient", I want to install this new package without checking other packages requirements (because on my dev machine "keboola/php-encryption" complains about crypt ext missing and other stuff).

What is the right command? Tried already update PACKAGE, but this fails:

$root: php composer.phar update google/apiclient       
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
- keboola/php-encryption dev-master requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.

Solution

  • If you want to ignore the specifics of your local system, you can use --ignore-platform-reqs flag. Keep in mind that it may result in unusable lockfile in production.

    Let's show it on imaginary scenario:

    • you don't have ext-crypt locally and neither in production.
    • there is package cryptX that
      • in cryptX:1.0 uses lib-crypt-polyfill (that does what ext-crypt does using PHP code)
      • but in cryptX:2.0 they changed the dependency to ext-crypt.

    Now if you were to install it normally, you'd get version 1 (which is the only one meeting the dependencies). But with --ignore-platform-reqs it just works as if whatever it wants is available in your system. So it happily installs version 2, which does not work on you machine, but what's more it won't work on you production server neither.