Once the Composer client is installed, you can access Composer repositories in Artifactory through its command line interface.
Composer repositories must be prefixed with api/composer in the path
When accessing a Composer repository through Artifactory, the repository URL must be prefixed with api/composer in the path. This applies to all Composer commands including composer install
.
For example, if you are using Artifactory standalone or as a local service, you would access your Composer repositories using the following URL:
http://localhost:8081/artifactory/api/composer/<repository key>
Or, if you are using Artifactory Cloud, the URL would be:
https://<server name>.jfrog.io/artifactory/api/composer/<repository key>
Once you have created a Composer repository, from the Application module go to Artifactory |Artifacts | Artifact Repository Browser and click Set Me Up to get code snippets you can use to set your Composer repository URL in your config.json
file.
Composer config.json file
Windows: %userprofile%\.composer\config.json
Linux: ~/.composer/config.json
Replace the Default Repository
You can change the default repository specified for the Composer command line in the config.json
file as follows:
{ "repositories": [ { "type": "composer", "url": "https://localhost:8081/artifactory/api/composer/composer-local"}, { "packagist": false } ] }
Working with a secure URL (HTTPS) is considered a best practice, but you may also work with an insecure URL (HTTP) by setting the secure-http configuration to false:
{ "config": { "secure-http" : false }, "repositories": [ ... ] }
GitHub Authentication
From November 2020, GitHub no longer accepts account passwords when authenticating via the REST API and instead requires the use of token-based authentication such as a personal access token for all authenticated API operations on GitHub.com.