{"id":13519713,"url":"https://github.com/ekino/php-mirroring","last_synced_at":"2025-03-31T14:31:03.990Z","repository":{"id":7036527,"uuid":"8312491","full_name":"ekino/php-mirroring","owner":"ekino","description":"[deprecated] Packagist and Github mirroring","archived":true,"fork":false,"pushed_at":"2016-05-28T13:10:05.000Z","size":23,"stargazers_count":55,"open_issues_count":0,"forks_count":8,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-11-02T02:33:21.517Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ekino.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-20T12:14:59.000Z","updated_at":"2024-01-29T07:49:46.000Z","dependencies_parsed_at":"2022-09-11T21:43:49.052Z","dependency_job_id":null,"html_url":"https://github.com/ekino/php-mirroring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekino%2Fphp-mirroring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekino%2Fphp-mirroring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekino%2Fphp-mirroring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekino%2Fphp-mirroring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekino","download_url":"https://codeload.github.com/ekino/php-mirroring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246482937,"owners_count":20784799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:02:02.254Z","updated_at":"2025-03-31T14:31:03.736Z","avatar_url":"https://github.com/ekino.png","language":"PHP","funding_links":[],"categories":["PHP","类库"],"sub_categories":["未归类"],"readme":"⚠️ Deprecated Project ⚠️\n=====================\n\nPlease 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. \n\nYou should now use: [https://github.com/rande/pkgmirror](https://github.com/rande/pkgmirror)\n\n\nPackagist and Github mirroring\n==============================\n\nExperiencing Github issues ? You want a local cache to speed up tests and deployment ?\n\n\nMirroring Packagist\n-------------------\n\n1. Set up a new host on your webserver : packagist.mycompany.com\n\n2. Go to the document root for the new host\n\n3. run `git clone git://github.com/ekino/php-mirroring.git .`\n\n4. run `cp config.php.sample config.php`\n\n5. edit rules: `vim config.php`\n\n6. run `php mirror.php` - this can take a while for the first one\n\n7. add a new cron job `sudo crontab -u www-data -e`:\n\n        0 */1 * * * cd /PATH_TO_DOCUMENT_ROOT \u0026\u0026 php mirror.php\n\nMirroring Github\n----------------\n\n1. Create a new mirror directory\n\n        mkdir mirrors/github.com\n\n2. Add new mirror\n\n        cd mirrors/github.com\n        git clone --mirror git://github.com/ekino/php-mirroring.git ekino/php-mirroring.git\n\n    Of course you need to repeat this operation for each mirror.\n\n3. Setup a cron to update the mirror:\n\n        0 */1 * * * /git/repositories/mirrors/update-mirrors.sh\n\n4. Add the file : `vim /git/repositories/mirrors/update-mirrors.sh`\n\n        #!/bin/sh\n        cd /git/repositories/mirrors/github.com\n\n        for i in */*.git; do\n          cd $i\n\n          url=`echo $i | sed \"s/.git//\"`\n\n          echo \"   \u003e check 404 on https://github.com/${url}\"\n          curl -ILs https://github.com/${url} | head -n 1 | grep \"HTTP/1.1 200 OK\" \u003e /dev/null\n\n          if [ $? -eq 0 ] ; then\n              echo \"   \u003e fetching git changes\"\n              git fetch\n          fi\n\n          #echo \"end ...\"\n          cd ../..\n        done\n\n\nUsages\n------\n\n### Using source mode with gitolite\n\n1. Setup a Gitolite\n\n2. Add a new entry\n\n        repo mirrors/..*\n            R = @team\n\n3. set the source mode to true\n\n        function include_source() \n        {\n            return true;\n        }\n\n### Using dist mode with a http server\n\n1. setup a new php instance with a dedicated vhost\n\n2. make sure the ``replace_dist_host`` function point to the correct vhost\n\n        function replace_dist_host(array $metadata)\n        {\n            list($vendor, $name) = explode(\"/\", $metadata['name']);\n\n            if (!preg_match('@(https://api.github.com/repos/|https://github.com/|https://bitbucket.org)([a-zA-Z0-9_\\-\\.]*)/([a-zA-Z0-9_\\-\\.]*)/(zipball|archive|get)/([a-zA-Z0-9\\.\\-]*)(|.zip)@', $metadata['dist']['url'], $matches)) {\n                return '';\n            }\n\n            $host = sprintf('http://packagist.mycompany.com/cache.php/github.com/%s/%s/%s.zip',\n                $matches[2],\n                $matches[3],\n                $metadata['dist']['reference']\n            );\n\n            return $host;\n        }\n\n        function include_dist() \n        {\n            return true;\n        }\n\n        function include_source() \n        {\n            return true; // set to false if you only want to expose distribution\n        }\n\n### Composer.json\n\n\n1. Make sure you have a clean project\n\n        rm -rf composer.lock vendor\n\n2. update the ``composer.json`` file to disable packagist and add the new one\n\n        {\n            \"repositories\":[\n                { \"packagist\": false },\n                { \"type\": \"composer\", \"url\": \"http://packagist.mycompany.com\"}\n            ],\n            \n            // ...\n        }\n\n  If you are using non-composer packages, use the correct source url when adding them.\n\n        {\n            \"repositories\":[\n                {\n                    \"type\": \"package\",\n                    \"package\": {\n                        \"name\": \"documentcloud/underscore\",\n                        \"version\": \"dev-master\",\n                        \"source\": {\n                            \"url\": \"git@git.mycompany.com:/mirrors/github.com/documentcloud/underscore.git\",\n                            \"type\": \"git\",\n                            \"reference\": \"master\"\n                        }\n                    }\n                }\n                \n                // ...\n            ],\n            \n            // ...\n        }\n\n\n3. Install the dependencies\n\n        php composer.phar install\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekino%2Fphp-mirroring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekino%2Fphp-mirroring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekino%2Fphp-mirroring/lists"}