Connect Composer to Artifactory

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

To resolve dependencies from Composer repositories in Artifactory, configure the config.json file to connect the Composer client to Artifactory.

Prerequisite: Before connecting your Composer client to Artifactory, you must have an existing Composer repository in Artifactory. For more information, see Create a Composer Repository.

To connect the Composer client to Artifactory:

  1. Add the following snippet to your config.json file:

    { 
        "repositories": [ {
            "type": "composer", "url": "https://[JFrogPlatformURL]/artifactory/api/composer/<REPO_NAME>"}, 
            {"packagist": false} 
        ]
    }

    Where:

    • [JFrogPlatformURL]: The URL of your JPD

    • <REPO_NAME>: The name of the target repository

    For example:

    {
        "repositories": [
            {"type": "composer", "url": "https://company.jfrog.io/artifactory/api/composer/php-local"},
            {"packagist": false}
        ]
    }
  2. Optionally, if you need to with a non-secure URL like HTTP, add the following snippet to the config.json file:

    "config": {
       "secure-http" : false
    }
  3. To authenticate to Artifactory, add credential snippets to your auth.json file:

    {
        "http-basic": {
            "[JFrogPlatformURL]": {
                "username": "<USERNAME>",
                "password": "<AUTH>"
            }
        }
    }

    Where:

    • [JFrogPlatformURL]: The hostname of your JPD

    • <USERNAME>: Your Artifactory username

    • <AUTH>: Your Artifactory identity token

    For example:

    {
        "http-basic": {
            "company.jfrog.io": {
                "username": "jeffry",
                "password": "51HnvD0A1g2q3n4b5F6g7H8j9K0l1m2N3o4P5q6R7s8T9u0V1w2X3y4"
            }
        }
    }

Note

You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.

Next steps: