官术网_书友最值得收藏!

Using private packages

Sometimes, you need to use a private repository on GitHub or another location. I will cover here how to set this up in your composer.

Getting ready

We need a private repo, so if you have it and its composer.json is set up properly, you will be set from there.

How to do it...

  1. First, go to GitHub and navigate to SettingsPersonal access tokens:
  2. At the command line, type this:
    >composer config –g github-oauth.github.com THE_TOKEN_FROM_ABOVE. 
  3. Then, edit composer.json so that there are two new sections:
  4. Then, let's tell the composer to install this:
    >rm –rf composer.lock vendor
    >composer install
    

How it works...

Alright, let's talk about these steps. The first one is to make sure we are setting up our Homestead or Mac for easy access to the private repository. This is really key as well if you are doing 2FA on your GitHub account (which you should be doing). Step 2 wraps this up by adding it to your ~/.composer configuration.

In the next part, we edit the composer.json file; and here, we see just how powerful Composer really is. It uses conventions and Packagist to easily organize and pull in projects; it also allows you to override this information in the repositories section of the file. Since the repository will not be in Packagist as it is private, the Composer will need to know where to look and this is made possible by this section.

Finally, I do install since I feel it is faster. You can update it or you can do whatever is required as well.

That's it, you will now see this private repository in your vendor/ folder.

See also

主站蜘蛛池模板: 格尔木市| 兴城市| 泽库县| 伊通| 休宁县| 库车县| 乾安县| 渑池县| 平乐县| 乌苏市| 武强县| 乐清市| 河曲县| 嵊泗县| 繁昌县| 扎鲁特旗| 紫金县| 奎屯市| 阳城县| 青河县| 苍梧县| 威海市| 和顺县| 盈江县| 衡南县| 鹿邑县| 福鼎市| 永嘉县| 崇义县| 商南县| 平果县| 昆山市| 安新县| 青冈县| 平果县| 乌恰县| 察隅县| 连城县| 巴马| 永安市| 新蔡县|