Skip to content
[deprecated] Packagist and Github mirroring
Branch: master
Clone or download
Latest commit 98afda3 May 28, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
CHANGELOG.txt [patch-warnings] fix some warnings when to inexsitant array indexes + cs Aug 5, 2014
cache.php do not store branch version Mar 17, 2016

⚠️ Deprecated Project ⚠️

Please note, the current implementation is not suitable anymore and does not work anymore with composer if you are using an ext3 partition. Also, the mirroring solution requires a dedicated git host to server repository which is not an easy and simple task on the long run.

You should now use:

Packagist and Github mirroring

Experiencing Github issues ? You want a local cache to speed up tests and deployment ?

Mirroring Packagist

  1. Set up a new host on your webserver :

  2. Go to the document root for the new host

  3. run git clone git:// .

  4. run cp config.php.sample config.php

  5. edit rules: vim config.php

  6. run php mirror.php - this can take a while for the first one

  7. add a new cron job sudo crontab -u www-data -e:

     0 */1 * * * cd /PATH_TO_DOCUMENT_ROOT && php mirror.php

Mirroring Github

  1. Create a new mirror directory

     mkdir mirrors/
  2. Add new mirror

     cd mirrors/
     git clone --mirror git:// ekino/php-mirroring.git

    Of course you need to repeat this operation for each mirror.

  3. Setup a cron to update the mirror:

     0 */1 * * * /git/repositories/mirrors/
  4. Add the file : vim /git/repositories/mirrors/

     cd /git/repositories/mirrors/
     for i in */*.git; do
       cd $i
       url=`echo $i | sed "s/.git//"`
       echo "   > check 404 on${url}"
       curl -ILs${url} | head -n 1 | grep "HTTP/1.1 200 OK" > /dev/null
       if [ $? -eq 0 ] ; then
           echo "   > fetching git changes"
           git fetch
       #echo "end ..."
       cd ../..


Using source mode with gitolite

  1. Setup a Gitolite

  2. Add a new entry

     repo mirrors/..*
         R = @team
  3. set the source mode to true

     function include_source() 
         return true;

Using dist mode with a http server

  1. setup a new php instance with a dedicated vhost

  2. make sure the replace_dist_host function point to the correct vhost

     function replace_dist_host(array $metadata)
         list($vendor, $name) = explode("/", $metadata['name']);
         if (!preg_match('@(||[a-zA-Z0-9_\-\.]*)/([a-zA-Z0-9_\-\.]*)/(zipball|archive|get)/([a-zA-Z0-9\.\-]*)(|.zip)@', $metadata['dist']['url'], $matches)) {
             return '';
         $host = sprintf('',
         return $host;
     function include_dist() 
         return true;
     function include_source() 
         return true; // set to false if you only want to expose distribution


  1. Make sure you have a clean project

     rm -rf composer.lock vendor
  2. update the composer.json file to disable packagist and add the new one

             { "packagist": false },
             { "type": "composer", "url": ""}
         // ...

If you are using non-composer packages, use the correct source url when adding them.

                "type": "package",
                "package": {
                    "name": "documentcloud/underscore",
                    "version": "dev-master",
                    "source": {
                        "url": "",
                        "type": "git",
                        "reference": "master"
            // ...
        // ...
  1. Install the dependencies

     php composer.phar install
You can’t perform that action at this time.