Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer create-project from private repo

I have a private project hosted on Bit Bucket. I have an SSH key setup. Is there a way I can use the php composer create-project vendor/name path command in the same way as If it was on Packagist?

like image 227
Luke Snowden Avatar asked Aug 10 '13 08:08

Luke Snowden


People also ask

What is private Packagist?

Private Packagist is a commercial package hosting product offering professional support and web based management of private and public packages, and granular access permissions.

Where does composer get packages from?

Composer downloads directly from the source, e.g. Packagist only knows those source and tells your composer instance where to go. It does this by downloading a bunch of json files from Packagist.org that have all the infos.


2 Answers

Well there are different ways to accomplish this one being the use of a composer repository that is used instead of packagist.org, which is a better more centralized way to manage your private composer packages. The other method is to use a composer.json that incorporates your private repos within your environments, per environment.

First

Composer allows you to use private repositories to create projects.

Like so...

composer create-project vendor/name path --repository-url=http://repo.yourcomposerrepo.com 

Since you won't submit a private package to packagist. That url just needs a packages.json file at minimum, you could use satis or your own packagist if you want a more dynamic solution to the packages.json.

The method for using composer.json applies to already created projects that will use custom repositories for private packages, not for creating new projects from private repositories. Use the next method if you want to go down a similar route.

Second

Configure your private repository into your config.json globally for your environment. Then like normally..

composer create-project vendor/name path 
like image 90
riotCode Avatar answered Oct 04 '22 05:10

riotCode


Yes, Composer allows you to add private projects as 'repositories' to your composer.json file. So therefore you can include private projects into another project.

It provides support for GitHub and Bitbucket (as well as SVN and Mercurial).

You need to modify your composer.json file to look something like this:

{     "repositories": [ {         "type": "package",         "package": {             "name": "TheShiftExchange/test",             "version": "1.0.0",             "source": {                 "url": "https://github.com/TheShiftExchange/test.git",                 "type": "git",                 "reference": "master"               }          }     }],     "require": {         "laravel/framework": "4.0.*",         "TheShiftExchange/test": "1.0.*"     }, } 
like image 26
Laurence Avatar answered Oct 04 '22 06:10

Laurence