Issue
I have a main php project that needs a php component developed by me, that i intend to reuse in other projects, the component is in the main project vendor directory. However pushing to Github the component, go to the main project, running composer update is time consuming. In order to speed up the development of the component, is there a way to include the local component project into the main project?
Solution
This is how I do local composer package development.
- Create a
vendor-repo
folder next to the vendor folder. - Create a directory for the vendor and project name for example
vendor-repo/vendorname/packagename
- Create a git repo inside the
packagename
folder and build your composer package complete withcomposer.json
etc. - Add your local repository to the main
composer.json
(the one that requires your package). You can also disable the packagist repo by adding the"packagist": false
as per the example below. This will speed things up and is a good idea if you aren't using any packages from packagist.
"repositories": [
{
"type": "path",
"url": "vendor-repo/vendorname/packagename"
},
{
"packagist": false
}
]
Then when you run composer update
it will get your package from your local repo rather than needing to get it from GitHub.
Answered By - developerbmw
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.