Using Composer to install local GIT Repositories
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.
