Click here to Skip to main content
15,896,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Recently I was trying my hands to make my own package on Packagist. I have successfully made a project and uploaded it to GitHub on this link GitHub - hitswa/composer-package-test: I am just trying to create a composer package[^]

After doing so I successfully made project on Packagist hiteshrohilla/common - Packagist[^] but when I try to fetch it using composer it gives me the following error

composer requir hiteshrohilla/common


  [InvalidArgumentException]
  Could not find package hiteshrohilla/common.

  Did you mean this?
      hiteshrohilla/common


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...


What I have tried:

I tried to search and apply various solutions by searching on Google. however, I don't find much about it. One relevant result is [^] on stackoverflow.

I tried to check my composer.json file which is as follow

{
    "name": "hiteshrohilla/common",
    "description": "common files used in development of a php project",
    "keywords": ["php","common"],
    "type": "library",
    "version": "1.0.0",
    "minimum-stability": "stable",
    "homepage": "http://hiteshrohilla.com/",
    "require": {
        "php": "^5.3.3 || ^7.0",
        "ext-mysqli": "*"
    },
    "require-dev": {},
    "conflict": {},
    "repositories": [
        {
            "type": "path",
            "url": "https://github.com/hitswa/composer-package-test.git"
        }
    ],
    "license": ["Creative Commons Attribution-ShareAlike 4.0 International License",
                "Creative Commons Attribution 3.0 License"],
    "authors": [
        {
            "name": "Er. Hitesh Kumar (Rohilla)",
            "email": "rohilla.hitesh@gmail.com",
            "homepage": "http://hiteshrohilla.com/",
            "role": "Developer"
        }
    ],
    "support": {
        "email": "rohilla.hitesh@gmail.com"
    },
    "time": "2018-01-15 00:00:00",
    "autoload":{
        "psr-4":{
            "Hiteshrohilla\\":"src/Hiteshrohilla"
        }
    }
}


Please let me know what wrong I am doing and guide me and correct me.
======================================================================

UPDATE:

Now I am able to fetch the package from the composer. How? by following way

Step 01: I made an empty project directory where I want to fetch this package.

Step 02: Then I made a composer.json file and add following code to it

{
    "name": "testapp",
    "require": {
        "hiteshrohilla/common": "dev-master"
    }
}


Step 03: Then I run following command in terminal at this address of project directory

composer install


==========================================================

Well, I still think why I am unable to fetch the repository directly from composer CLI. Maybe because there is no release on GitHub.
Posted
Updated 15-Jan-18 2:54am
v2

1 solution

This is because of your package code does not contain any tags in git repository.
Use below lines to add tag and then push it to repo.
e.g.
git tag -a 1.0.0
git push --tags

After that you can use composer require hiteshrohilla/common.

Thanks,
Afraz Ahmad
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900