Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Last active April 18, 2024 21:41
Show Gist options
  • Save mfurlend/f5340de02fba166f9a84 to your computer and use it in GitHub Desktop.
Save mfurlend/f5340de02fba166f9a84 to your computer and use it in GitHub Desktop.
composer require git repository
{
"name": "my_vendor_name/my_package",
"description": "My Package Description",
"license": "GPL-3.0",
"autoload": {
"classmap": [ // search these directories for classes
"lib/"
]
},
"repositories": {
"php-console-color": { // pseudonym of git repo
"type": "package",
"package": {
"name": "coryjthompson/php-console-color", // name of git repo
"version": "1.0",
"source": {
"url": "https://github.com/coryjthompson/php-console-color.git", // url to repo
"type": "git", // vcs or git
"reference": "origin/master"
}
}
}
},
"require": {
"coryjthompson/php-console-color":"1.0"
}
}
@kuldeep198811
Copy link

kuldeep198811 commented Sep 9, 2019

what should be the command for it?

@binaryweavers
Copy link

what should be the command for it?

I think composer update would do the job

@programeriss
Copy link

composer require coryjthompson/php-console-color

@tiagoa
Copy link

tiagoa commented Apr 29, 2020

Thank you!

@celorodovalho
Copy link

It doesn't work, can you explain me why?

    "repositories": {
        "wp-mvc": {
            "type": "package",
            "package": {
                "name": "tombenner/wp-mvc",
                "version": "1.5",
                "source": {
                    "url": "https://github.com/tombenner/wp-mvc.git",
                    "type": "git",
                    "reference": "origin/master"
                }
            }
        }
    },
    "require": {
        "tombenner/wp-mvc": "1.5"
    },

@richardkeep
Copy link

richardkeep commented Oct 30, 2020

@celorodovalho

use this

"repositories": {
    {
        "type": "package",
        "package": {
            "name": "tombenner/wp-mvc",
            "version": "1.5",
            "source": {
                "url": "https://github.com/tombenner/wp-mvc.git",
                "type": "git",
                "reference": "origin/master"
            }
        }
    },
}
"require": {
    "tombenner/wp-mvc": "1.5"
},

@celorodovalho
Copy link

@richardkeep
If your intention was to say:

    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "tombenner/wp-mvc",
                "version": "1.5",
                "source": {
                    "url": "https://github.com/tombenner/wp-mvc.git",
                    "type": "git",
                    "reference": "origin/master"
                }
            }
        }
    ],
    "require": {
        "php": ">=5.4",
        "tombenner/wp-mvc": "1.5"
    },

It doesn't work as well.

@adityastic
Copy link

@celorodovalho try this:

"repositories": [
        {
            "type": "git",
            "url": "https://github.com/tombenner/wp-mvc.git"
        }
    ],
"require":{
    "tombenner/wp-mvc": "dev-master"
}

@celorodovalho
Copy link

@adityastic I tried it already, I try with all possible ways.
The only way that I could make it work is like that:

    {
      "type": "package",
      "package": {
        "name": "wp-plugins/wp-mvc",
        "version": "1",
        "type": "wordpress-plugin",
        "source": {
          "url": "https://github.com/tombenner/wp-mvc.git",
          "type": "git",
          "reference": "master"
        }
      }
    }
  "require": {
    "wp-plugins/wp-mvc": "^1"
  }

I really don't know why, it should work as you suggested.

@grandeto
Copy link

grandeto commented Apr 5, 2021

In case you forked the repo it works like this way

"repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        },
        {
          "type": "vcs",
          "url": "https://github.com/grandeto/faker",
          "no-api": true
        }
    ],
"require": {
   "fzaninotto/faker": "dev-master"
}

https://getcomposer.org/doc/02-libraries.md

@kea137
Copy link

kea137 commented May 3, 2021

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment