Skip to content
Advertisement

How can I use Artifactory as a caching proxy for my PHP composer dependencies from packagist?

I want to use Artifactory as a caching proxy for my PHP composer dependencies.

I have been able to manually create a remote repository and configure composer to use Artifactory instead of packagist.

The problem is that my project has a lot of dependencies (because dependencies have dependencies).

It’s going to be impossible to use Artifactory if I have to do this manually.

How can I create a mirror of all my dependencies (including indirect dependencies) starting from my composer.json?

Advertisement

Answer

A remote repository in Artifactory is usually used to mirror another repository / registry, serving multiple packages. There shouldn’t be a need to setup a new remote repository for each dependency (i.e. package).

Since the majority of the packages in packagist.org are served from github.com, configuring a single remote repository that resolves the registry index files from packagist and the binaries from github should be enough.

If you depend on packages which are not hosted in github, you can simply add an additional remote repository that mirrors that other git provider. In this case you should also define a virtual repository that aggregates all the relevant repositories and use that one to resolve your dependencies.

For more details – see the documentation for PHP Composer Remote Repositories.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement