Today we will learn about how we can use github as package source in composer. Composer is a package manager for PHP, all packages that composer have are mostly manged from packagist. We can also use github as package source for composer. Below is the format how we can define a package which source code is available in github to be available to loaded as a composer package.
Composer.json
"require": {
"lpkapil/phpdocx": "1.0.0"
},
"repositories": [
{
"type": "package",
"package": {
"name": "lpkapil/phpdocx",
"version": "1.0.0",
"source": {
"url": "https://github.com/lpkapil/phpdocx.git",
"type": "git",
"reference": "master"
}
}
}
]
JSONYou need to add have above code snippet in your composer.json file and you can update url (git repo url), reference (git branch) & version (reference version), according to your project.
Once user will run composer install command, it will fetch the package source code in vendor/package-name from reference (git branch) specified in composer.json file.