Skip to content



Repository files navigation

📦 Packagist Mirror

Build Status docker Status docker pulls Minimum PHP Version Packagist Codecov Quality Score Mentioned in Awesome composer

❤️ Recommended by ❤️

A mirror for that regularly caches packages from one or more main mirrors to add to a distributed package repository.

Mirror creation

If you're using PHP Composer, commands like create-project, require, update, remove are often used. When those commands are executed, Composer will download information from the packages that are needed also from dependent packages. The number of json files downloaded depends on the complexity of the packages which are going to be used. The further you are from the location of the server, the more time is needed to download json files. By using a mirror, it will save you time when downloading json because the server location is closer.

⚙️ How it works?

This project aims to create a local mirror with ease, allowing greater availability for companies/countries that want to use composer without depending on the infrastructure of third parties. It is also possible to create a public mirror to reduce the load on the main repository and better distribute requests around the world, helping make the packagist ecosystem faster as a whole!

When creating a mirror, you add a list of other mirrors to use for initial sync, which pulls all packages to your local machine. After the mirror is created and synced, the next runs will only pull updates. If any mirror fails to deliver a metadata file, the client will fallback to its configured main mirror, whether that be or otherwise. If the client encounters an installation problem or loses connection to a mirror, it can return from where it stopped running.

Mirror creation

🌎 Packagist public metadata mirrors observatory around the world

🛫 Amazing data mirrors used to download repositories metadata built using this recommended repository or another:

Lists are ordered by country and sync frequency.

Location Mirror Maintainer Github Sync Since
Brazil Webysther main Continuously Q3'17
China Eagle Wu fork Every minute Q3'18
China Shanghai Jiao Tong University fork Every hour Q2'19
Czech Republic HOSTUJ TO fork Every 5 minutes 🆕Q1'20
Finland Niko Granö fork Every 5 minutes 🆕Q2'20
Germany Benjamin Hesse fork Every minute 🆕Q3'20
India Varun Sridharan fork Every minute Q2'19
India Vallabh Kansagara fork Every 5 minutes Q4'19
Indonesia Indra Gunawan fork Every 30 seconds Q3'18
Indonesia Ian Mustafa fork Every 30 seconds Q3'19
Indonesia Telkom University fork Every 5 minutes 🆕Q1'20
Japan Studio Umi fork Every minute 🆕Q1'20
South Africa SolidWorx fork Every 5 minutes Q3'18
South Korea PackagistKR fork Every minute Q3'18
Thailand Jarak Kritkiattisak fork Every 5 minutes Q4'19
USA Wikimedia fork Every 5 minutes Q3'18
Taiwan Peter fork Every 5 minutes 🆕Q2'20
Taiwan Peter fork Every 5 minutes 🆕Q2'20
Vietnam Long Nguyen main Every 5 minutes 🆕Q3'20

⚠️ Not based on this source code:

Location Mirror Maintainer Github Sync Since
China Aliyun Every 5 minutes
China Tecent Cloud Every day
Japan Hiraku forked Every 2 minutes Q4'14
Japan Kawax another Every hour Q4'18

🛑 Not working as a mirror of (checked at Q1'20):

Location Mirror Maintainer Github Reason At least
China Huawei Cloud Outdated Q3'19
China Outdated Q4'19

If you know any new mirror based or not on this one, please create a issue or a pull request with the new data.

Check status page for health mirror's.

World Map

This map shows working mirrors from above at the country level. The colors represent the topology drawn below.

🚀 Create your own mirror


💡Tip: use a machine with at least 2GB of RAM to avoid using the disk or swap space during sync.

⚠️ When syncing from DATA_MIRROR or MAIN_MIRROR, your server encodes and decodes all packages as .gz files to save disk space. You may need to enable server-side decoding for legacy composer clients that ask for decompressed packages.

There are currently three supported methods for creating your own mirror.

In all three methods, you need to clone the repository and copy .env.example to .env and modify to include your values instead of the defaults.

# Clone this repository
$ git clone

# Setup environment variables
$ cd packagist-mirror
$ cp .env.example .env
$ nano .env

Docker Compose

Run the following commands to start a container for Nginx, PHP-FPM, and a worker that runs cron jobs.

# Start all Docker containers
$ docker-compose up -d

# Follow log output
$ docker-compose logs -f

Once the initial sync has finished, open https://localhost:9248 to see your site.

💡Tip: Add -f between docker-compose and up or down while running the above commands. If you are using traefik, the services in this docker-compose file contain labels used by a running traefik container to automatically route traffic matching those labels to that container. It even auto-renews LetsEncrypt certificates for you.

Docker Nginx PHP

First, add the following line to /etc/crontab to tell the host to start a container for the packagist-mirror image on boot, replacing the values for each -e flag with your own. This will start the initial sync and generate the website files to be served by nginx.

Learn about more the available options for this docker image here.

* * * * * root docker run --name mirror --rm -v /var/www:/public \
-e APP_COUNTRY_NAME='Brazil' \
-e MAINTAINER_MIRROR='Webysther' \
-e URL='' \

Next, add the following to /etc/nginx/sites-available/ to host the website files:

server {


    location / {
        try_files $uri $uri/ =404;
        gzip_static on;
        gunzip on;

To monitor sync progress, run the following command:

docker logs --follow --timestamps --tail 10 mirror

Nginx PHP

After cloning the repository, run the following commands to configure for your host.

$ cd packagist-mirror && composer install
$ cp .env.example .env

Then, schedule the command to create and update the mirror:

$ php bin/mirror create -vvv

Nginx will now serve your mirror at the configured URL.

🐧 Development & Contributing

Please see CONTRIBUTING and CONDUCT for details.

🛣️ Roadmap


  • Support for Drupal metadata
  • Translate and index of mirror.
  • Fully IaC with terraform.
  • More recipes to AWS/Azure/GCP/DigitalOcean and another cloud providers.
  • Support for Heroku.
  • Support for kubernetes.


  • Support gz disabled for limited configuration access to Apache/Nginx.
  • Support full mirror mode: Github/Gitlab.
  • Integration with twity.
  • Integration with composer-registry-manager.

📋 Requirements

The following versions of PHP are supported by this version.

  • PHP >=7.2

🧪 Testing

$ vendor/bin/phpunit

🥂 Credits

💙 Other correlated projects

☮️ License

MIT License. Please see License File for more information.

FOSSA Status


Create a mirror of packagist







No packages published


  • PHP 94.0%
  • Shell 3.5%
  • Dockerfile 2.5%