Search code examples
phppackagedependenciescomposer-php

how to publish php package so it will download `"name/mypackage": "dev-build"`


I have the access of a PHP Package called "name/mypackage",

and in my local computer system there is a file called composer.json that looks like this,

{
    "require": {
        "name/mypackage": "dev-build"
    }
}

when i run composer install

it will show me this error Problem 1 - Root composer.json requires name/mypackage dev-build, found name/mypackage[dev-main] but it does not match the constraint.

So my question is what version should i use in publicly available name/mypackage package's composer.json file

{
    "name": "name/mypackage",
    "version": "<WHAT_SHOULD_I_USE_HERE_SO_IT_WILL_DOWNLOADS_IN_MY_COMPUTER>",
    "description": "PHP Package",
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "sachin"
        }
    ]
}

Thank You


Solution

  • According to the documentation on the composer.json schema

    Packagist uses VCS repositories, so the statement above is very much true for Packagist as well. Specifying the version yourself will most likely end up creating problems at some point due to human error.

    This means that the version name dev-main is inferred from the branch name main and therefore if you want to use dev-build as the version name to use you need a branch called build.

    It can also read tag names so if you tag a commit with say 1.0.0 then that will be used when requesting version 1.0.0 of your package.