Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify Composer package stability?

I have a git repository on Bitbucket, which is a Composer-enabled package (containing a composer.json that looks like this):

{
    "name": "foo/package",
    "version": "0.0.1"
}

I have another project that has this composer.json:

{
    "name": "foo/project",
    "repositories": [
        {
            "type": "vcs",
            "url": "[bitbucket git url]",
        }
    ],
    "require": {
         "foo/package": "*"
    }
}

If I try to run composer install, I get an error message:

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

  Problem 1
    - Installation request for foo/package * -> satisfiable by foo/package[dev-master].
    - Removal request for foo/package == 9999999-dev

If I add the following line to the project's composer.json, the error goes away and the package installs properly.

"minimum-stability": "dev"

I understand that Composer does not consider foo/package to be stable, which is why it says it can't find it, and adding the "minimum-stability" line tells it that foo/package is okay to install. But I don't know how to tell Composer that foo/package is stable.

Setting the required version to 0.0.1 instead of * does not work either, it just gives me this error instead:

 Problem 1
- The requested package stashimi/crawler 0.0.1 could not be found.

I found another Stack Overflow question which implies that giving foo/package a version number will indicate that it's stable, but this obviously isn't working, given the files above. What am I doing wrong?

like image 556
dirtside Avatar asked Jul 22 '26 18:07

dirtside


1 Answers

Okay, I figured out my own problem. Basically, when using a VCS repository, it looks for a tag with the given requirement version. In my case, since there was no tag 0.0.1 in my repo, Composer couldn't find it. Creating that tag in the repo solved the problem.

The other (probably more correct) way to solve this is to make the required version dev-master, which basically means "use the master branch in the repository." (Or whatever branch; Composer's documentation about the dev-X version specification is a bit confusing.)

like image 59
dirtside Avatar answered Jul 24 '26 09:07

dirtside



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!