PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] Composer require without dev-master

 January 18, 2022     composer-php, github, package, php     No comments   

Issue

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": "mirage.present@gmail.com"
        }
    ],
    "autoload": {
        "psr-4": {
            "MiragePresent\\Likeable\\": "src/"
        }
    },
    "require": {
        "php": ">=7.0"
    },
    "extra": {
        "laravel": {
            "providers": [
                "MiragePresent\\Likeable\\LikeableServiceProvider"
            ]
        }
    },
    "minimum-stability": "stable"
}

Solution

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": "developer@example.com",
            "homepage": "http://example.com/"
        }
    ],
    "support": {
        "email": "support@example.com"
    },
    "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



Answered By - Lawrence Cherone
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing