{"id":105096,"date":"2017-12-16T19:17:27","date_gmt":"2017-12-16T19:17:27","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=105096"},"modified":"2024-03-05T05:42:19","modified_gmt":"2024-03-05T05:42:19","slug":"install-packages-using-composer-local-git-repo","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/","title":{"rendered":"How to install packages using composer from local git repository"},"content":{"rendered":"\n<p>Composer is tool used to manage dependencies and file autoloading in your PHP project, it simply allows you to download packages from multiple repositories using composer.json&nbsp;file, by default it uses the <a href=\"https:\/\/packagist.org\/\">packagist<\/a>&nbsp;repository to search and install the packages, but uploading all the projects on packagist and then downloading from there sometimes not feasible, since you just need to test the project if it is working fine when installed from composer, since a huge project can have multiple requirements and dependencies&nbsp;so it is vital to test composer dependencies&nbsp;before offering it to the customer because if your project fails at the time of installation it will create a bad impression.<\/p>\n\n\n\n<p>Since mostly all the projects are managed on git, svn it will be best to install the packages directly from the local git repository. So let&#8217;s see how we can do that, first of all, you need to install composer on your system, please follow <a href=\"https:\/\/getcomposer.org\/doc\/00-intro.md\">this link<\/a> for installation.<\/p>\n\n\n\n<p>Composer allows you to define different types of repositories <a href=\"https:\/\/getcomposer.org\/doc\/04-schema.md#repositories\">check here<\/a><\/p>\n\n\n\n<p>to allow downloading from local repositories you must use type vcs, which will allow you to install packages directly from the private repository. I will explain the commands\u00a0that you can use to install\u00a0packages from local git repo:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&gt; composer config repositories.repo-name vcs https:\/\/git-url\/your-package.git\n&gt; composer require company\/package:dev-branch-name<\/pre>\n\n\n\n<p>Using above commands you can install from the private git repository, in the above commands the first one is to define the repository url, you can use your local repo file system path or ssh path as well, but to use ssh path you must add your system ssh key your git repo deploy keys, follow <a href=\"https:\/\/developer.github.com\/v3\/guides\/managing-deploy-keys\/\">this link<\/a> for better understanding.<\/p>\n\n\n\n<p>In the second command we are simply requiring the package with name company\/package and to specify the branch name we used dev-branch-name prefix &#8220;dev-&#8221; is fix and rest is branch name. The sample composer.json in the package will look like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">{\n  &quot;name&quot;:&quot;company\/package&quot;,\n  &quot;description&quot;:&quot;this is test package&quot;\n}<\/pre>\n\n\n\n<p>the above is a very basic composer file just to show you the package name, there can be&nbsp;a lot&nbsp;more options.<\/p>\n\n\n\n<p>Hope this will help you in module development and testing.<\/p>\n\n\n\n<p>Thanks \ud83d\ude42 .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Composer is tool used to manage dependencies and file autoloading in your PHP project, it simply allows you to download packages from multiple repositories using composer.json&nbsp;file, by default it uses the packagist&nbsp;repository to search and install the packages, but uploading all the projects on packagist and then downloading from there sometimes not feasible, since you <a href=\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-105096","post","type-post","status-publish","format-standard","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install packages using composer from local git repository - Webkul Blog<\/title>\n<meta name=\"description\" content=\"since a huge project can have multiple requirements and dependencies\u00a0so it is vital to test composer dependencies\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install packages using composer from local git repository - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"since a huge project can have multiple requirements and dependencies\u00a0so it is vital to test composer dependencies\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-16T19:17:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-05T05:42:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ashutosh Srivastava\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashutosh Srivastava\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\"},\"author\":{\"name\":\"Ashutosh Srivastava\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5555025750ec4e4df34fadc78b083970\"},\"headline\":\"How to install packages using composer from local git repository\",\"datePublished\":\"2017-12-16T19:17:27+00:00\",\"dateModified\":\"2024-03-05T05:42:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\"},\"wordCount\":365,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"php\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\",\"url\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\",\"name\":\"How to install packages using composer from local git repository - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2017-12-16T19:17:27+00:00\",\"dateModified\":\"2024-03-05T05:42:19+00:00\",\"description\":\"since a huge project can have multiple requirements and dependencies\u00a0so it is vital to test composer dependencies\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install packages using composer from local git repository\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/5555025750ec4e4df34fadc78b083970\",\"name\":\"Ashutosh Srivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2f5312e6903909ffeb33aa5eb38e1c0bed8f498f92144f5f84065adf7e8708a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2f5312e6903909ffeb33aa5eb38e1c0bed8f498f92144f5f84065adf7e8708a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ashutosh Srivastava\"},\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/ashutosh\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install packages using composer from local git repository - Webkul Blog","description":"since a huge project can have multiple requirements and dependencies\u00a0so it is vital to test composer dependencies","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/","og_locale":"en_US","og_type":"article","og_title":"How to install packages using composer from local git repository - Webkul Blog","og_description":"since a huge project can have multiple requirements and dependencies\u00a0so it is vital to test composer dependencies","og_url":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-12-16T19:17:27+00:00","article_modified_time":"2024-03-05T05:42:19+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Ashutosh Srivastava","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ashutosh Srivastava","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/"},"author":{"name":"Ashutosh Srivastava","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5555025750ec4e4df34fadc78b083970"},"headline":"How to install packages using composer from local git repository","datePublished":"2017-12-16T19:17:27+00:00","dateModified":"2024-03-05T05:42:19+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/"},"wordCount":365,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["php"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/","url":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/","name":"How to install packages using composer from local git repository - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2017-12-16T19:17:27+00:00","dateModified":"2024-03-05T05:42:19+00:00","description":"since a huge project can have multiple requirements and dependencies\u00a0so it is vital to test composer dependencies","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/install-packages-using-composer-local-git-repo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to install packages using composer from local git repository"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/5555025750ec4e4df34fadc78b083970","name":"Ashutosh Srivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2f5312e6903909ffeb33aa5eb38e1c0bed8f498f92144f5f84065adf7e8708a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2f5312e6903909ffeb33aa5eb38e1c0bed8f498f92144f5f84065adf7e8708a6?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ashutosh Srivastava"},"sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/ashutosh\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/105096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=105096"}],"version-history":[{"count":4,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/105096\/revisions"}],"predecessor-version":[{"id":426040,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/105096\/revisions\/426040"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=105096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=105096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=105096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}