Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer require without dev-master

I have pushed a public package on my github. But now I can't require that package to my project as normal, I must specify dev-master version for finding it. I have tried to set "minimum-stability" : "stable", but It does not work. Also I have created release v0.1 with path to master branch. What can I do for using my package just ran composer require <vendor>/<package> command?

My composer.json file:

{
    "name": "miragepresent/likeable",
    "description": "Quick likes support",
    "keywords": ["likes support", "laravel", "eloquent", "like", "likes relation", "likeable"],
    "license": "MIT",
    "support": {
        "issues": "https://github.com/MiragePresent/Likeable/issues",
        "source": "https://github.com/MiragePresent/Likeable"
    },
    "authors": [
        {
            "name": "David Holovii",
            "email": "[email protected]"
        }
    ],
    "autoload": {
        "psr-4": {
            "MiragePresent\\Likeable\\": "src/"
        }
    },
    "require": {
        "php": ">=7.0"
    },
    "extra": {
        "laravel": {
            "providers": [
                "MiragePresent\\Likeable\\LikeableServiceProvider"
            ]
        }
    },
    "minimum-stability": "stable"
}
like image 321
David Goloviy Avatar asked Dec 30 '25 19:12

David Goloviy


1 Answers

Steps to add a public composer package.

Develop your package, and make sure you have a composer.json

{
    "name": "vendor/package",
    "description": "My awesome package",
    "license": "MIT",
    "keywords": ["awesome","keywords"],
    "homepage": "https://github.com/vendor/package",
    "authors": [
        {
            "name": "Mr Developer",
            "email": "[email protected]",
            "homepage": "http://example.com/"
        }
    ],
    "support": {
        "email": "[email protected]"
    },
    "require": {
        "additional/package": ">=0.1"
    },
    "autoload": {
        "psr-4": {
            "Package\\Namespace\\": "src"
        }
    }
}

Then push your code to your VCS.

Sign up to https://packagist.org and list it, by clicking Submit and entering your packages VCS url in the input box. Submit it and correct any errors thrown.

enter image description here

Once the package is added, go to your account and grab your API key: https://packagist.org/profile/

Then add a service on the VCS (github) so new tags notify packagist.

https://github.com/vendor/package/settings/installations

enter image description here

enter image description here

Then once complete, you should create a tag of your package:

git tag -a v0.0.1 -m "First release"

Then push that tag to the VCS:

git push origin v0.0.1

Then anyone can install your package simply by doing:

composer require vendor/package

like image 100
Lawrence Cherone Avatar answered Jan 02 '26 11:01

Lawrence Cherone