A blog for technology, SEO tips, website development and open source programming.

Composer and Github repository

0 983

The post will show how to add public git repo as a composer package. If you want to add your own git repo as a composer package you can use the code snippet below.

The attributes you will need to replace with your own:

Composer has a nice way of loading packages through Github or any VCS. You only specify your repo URL and it will automatically scan your composer.json for package info. Keep in mind that repositories have a higher priority over Packagist when installing or updating.


If you made some changes to the local package and run composer update before pushing to Github you will lose them.

Branches are used for versioning your package. Version names can either be numbered like 1.0, 1.0.*, etc, or you’ll have to prefix your branch name with dev-*, in our example the dev-master version will look for the master branch.

Composer and Github repository extra tip

To make it even better, you can tag releases on Github and then specify that tag as the package version in place of dev-master, since being tied to master can be dangerous for production sites. Our basic workflow for this is:

git add -A
git commit -m 'add some cool new feature'
git tag 1.1.0 # Or whatever your new version is
git push origin master --tags

Now, you can require your package by that new version number.

Follow me on Instagram


Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More