phpcomposer-phppackagistsatis

How to to add permanently access to install private packages hosted by SATIS with access restriction in composer


I would like to know how to add permanently credential to install private packages hosted by SATIS with access restriction through composer.

Private packages are hosted by SATIS and have HTTP BASIC AUTH access restrictions.

I ve added them in composer.json like this :

"require": {
  "vendor/privatepackage": "^1.0"
},
"repositories": [
 {
  "type": "composer",
  "url": "https://myprivatepackages.io"
 }
],

When i execute php composer.phar install i would like to not have to enter each time the needed credentials.


Solution

  • There are a couple of ways to achieve this, outlined in the Composer documentation.

    In the repository path

    You can hard-code the credentials in the repository path in your composer.json, like this:

    "repositories": [
      {
        "type": "composer",
        "url": "https://username:password@myprivatepackages.io/"
      }
    ]
    

    This is often not an ideal solution since it means everyone who has access to your package also has access to your private repository.

    Using auth.json

    You can also create a file named auth.json in your COMPOSER_HOME directory (this defaults to ~/.composer/). There, you can specify access credentials for multiple repositories, which will be shared across your system. Alternatively, you can place this file in the root of your package, (but make sure it doesn't get added to version control, using .gitignore or similar).

    {
      "http-basic": {
        "myprivatepackages.io": {
          "username": "username",
          "password": "password"
        }
      }
    }