Using Composer to install local GIT Repositories

Rich Barrett
Jul 21, 2017 · 1 min read

When developing packages for use with Composer it’s useful to be able to install it locally to test it.

Here’s how you do it:

In your package, format your composer.json file with the parameters name and version required by composer to make it ‘installable’. You might also want to use the autoload parameter to specify where to find they key components of your package:

{
"name": "yourpackage/yourpackage",
"version": "1.0",
"require": {
"php": ">=5.6.0"
},
"autoload": {
"classmap": [
"yourclass.php"
]
}
}

In the project where you want to install the local package, reference it in the composer.json like this:

{
"repositories": [
{
"type": "path",
"url": "/your/local/path/to/package"
}
],
"require": {
"yourpackage/yourpackage": "*"
}
}

This is a pretty basic example but something I use frequently so is here as much for my own reference as anybody else's.

)

Rich Barrett

I’m a logistics technology, e-commerce, cross-border shipping & fulfilment expert. CTO at The Parcel Monkey Group, a globally operating logistics tech company.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade