Search code examples
phpexceptioncomposer-phppackagist

Unable to create composer package - InvalidArgumentException


I have been trying to create a simple composer package. But I'm stuck with the following issue. Dont know how to resolve this.

[InvalidArgumentException]                                                   
Could not find package sarav/sample-package at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability   

Package Url : https://packagist.org/packages/sarav/sample-package

I ran the following composer command

composer require sarav/sample-package

My composer contents

{
    "name": "sarav/sample-package",
    "description": "Sample package",
    "type": "Library",
    "license": "MIT",
    "authors": [
       {
          "name": "Sarav",
          "email": "[email protected]"
       }
    ],
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.3.0"
    },
   "autoload": {
       "psr-0": {
          "Sarav": "src/"
       }
   }
}

Solution

  • Your package config looks good to me, but your Git repo doesn't have any tagged versions.

    Use git tag v1.0.0 or whatever version is appropriate, then git push origin --tags to update on GitHub.

    Alternatively, you can go without tagged versions by specifying the master branch when you require the package, like so:

    composer require sarav/sample-package dev-master

    You can require any branch in this manner, but the dev- prefix is mandatory.