ARTIFACTORY: How to integrate PHP composer with Artifactory

Rasul Imanov
2022-06-23 08:48

Setup (in Artifactory)

To get started: 

  • Go to the top right corner of the screen and click the "Welcome, admin" dropdown
  • Select Quick Setup
  • Select Composer
  • Enter your repository prefix and repositories are created

Fine tuning: When setting up your Remote PHP Repository, it is really important to navigate over to the repository
(Administration -> Repositories -> Repositories -> Remote -> <repo-key>) and edit the Registry URL that Artifactory resolves remote artifacts from.

User-added image

Also navigate over to your Virtual PHP Repository ((Administration -> Repositories -> Repositories -> Virtual -> <repo-key>) and confirm that your Virtual Repository resolves from local and remote. You may also add additional repositories under this list if you would like to resolve them from different remote locations. 

User-added imageSetup (in Composer)  

After our repositories are all set in Artifactory, we can go ahead and integrate these into our composer project by following the below steps:
Navigate into your project folder and locate your composer.json or config.json file 
Configure the "repositories" tag to use your virtual repository so both local and remote can be used(ex: <art-url>/artifactory/api/composer/<repository key>)

User-added image