Search code examples
laravelcomposer-phppackagist

Required package in composer.json not found


I have created using the workbench of Laravel a package and uploded it to Packagist under pica/pica-base. The package contains the following require statement:

"require": { "php": ">=5.4.0", "illuminate/support": "4.2.*", "gregwar/captcha": "dev-master" },

When I try to install my pica/pica-base package it fails stating the following error message:

Your requirements could not be resolved to an installable set of packages.

Problem 1 - pica/pica-base dev-master requires gregwar/captcha dev-master -> no matching package found. - pica/pica-base dev-master requires gregwar/captcha dev-master -> no matching package found. - Installation request for pica/pica-base dev-master -> satisfiable by pica/pica-base[dev-master].

On advice of the FAQ I also tried the procedure with 'dev'in staed of 'dev-master'with the gregwar/captcha package but with the same result.

I don't understand this because with the exact same requirement I can install the gregwar-package in any other project. And the link to the package shows up in the page of my package on Packigist (https://packagist.org/packages/pica/pica-base).

So why does this fail?

Thanks for efforts!


Solution

  • By default, Composer uses only stable packages when calculating your dependencies. There are two ways to override this if you want to use an unstable (dev-master) package:

    1. In your root composer.json, require a dev-master version of a package (this is why you have no problem getting the pica/pica-base package, as it is in your root composer.json)
    2. In your root composer.json, set the minimum-stability flag to dev:

      "require": {
          ...
      },
      "minimum-stability": "dev"
      

    So you can basically do one of the following things:

    1. Add the gregwar/captcha dependency in your root composer.json (the one of your Laravel project)
    2. Add "minimum-stability": "dev" to your root composer.json.

    I recommend going for the second option. If you do so, you might want to also add the prefer-stable flag, in order to make sure that not all packages are downloaded in unstable versions:

    "require": {
        ...
        "pica/pica-base": "dev-master"
    },
    "minimum-stability": "dev",
    "prefer-stable": true