{"id":44882526,"url":"https://github.com/phlib/db-helper-replication","last_synced_at":"2026-02-17T16:31:02.076Z","repository":{"id":42508313,"uuid":"409079603","full_name":"phlib/db-helper-replication","owner":"phlib","description":"DB helpers to complement phlib/db","archived":false,"fork":false,"pushed_at":"2025-02-11T13:51:53.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-28T06:25:47.359Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phlib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-22T05:49:00.000Z","updated_at":"2025-02-11T13:51:57.000Z","dependencies_parsed_at":"2025-04-16T18:13:38.363Z","dependency_job_id":null,"html_url":"https://github.com/phlib/db-helper-replication","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"058380d353e99e2749e6b93dd37fd650ba17b565"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/phlib/db-helper-replication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fdb-helper-replication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fdb-helper-replication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fdb-helper-replication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fdb-helper-replication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phlib","download_url":"https://codeload.github.com/phlib/db-helper-replication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fdb-helper-replication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29549795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-02-17T16:31:01.262Z","updated_at":"2026-02-17T16:31:02.071Z","avatar_url":"https://github.com/phlib.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phlib/db-helper-replication\n\n[![Code Checks](https://img.shields.io/github/actions/workflow/status/phlib/db-helper-replication/code-checks.yml?logo=github)](https://github.com/phlib/db-helper-replication/actions/workflows/code-checks.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/phlib/db-helper-replication.svg?logo=codecov)](https://codecov.io/gh/phlib/db-helper-replication)\n[![Latest Stable Version](https://img.shields.io/packagist/v/phlib/db-helper-replication.svg?logo=packagist)](https://packagist.org/packages/phlib/db-helper-replication)\n[![Total Downloads](https://img.shields.io/packagist/dt/phlib/db-helper-replication.svg?logo=packagist)](https://packagist.org/packages/phlib/db-helper-replication)\n![Licence](https://img.shields.io/github/license/phlib/db-helper-replication.svg)\n\nDB helpers to complement phlib/db\n\nThis package, *db-helper-replication*, is split out from *phlib/db-helper*\ndue to the additional process-control dependencies which users of the more\ntypical helpers may not require or have available.\n\n## Installation\n\n```php\ncomposer require phlib/db-helper-replication\n```\n\n## Usage\n\n### Replication\n\nThe Replication helper monitors replica lag, which it stores in Memcache. This\nknown lag can then be used to throttle long-running processes by introducing\nvariable amounts of sleep.\n\nSet up replica monitoring using the CLI script\n(you might consider using Monit to run this automatically):\n\n```sh\n./vendor/bin/db replication:monitor -c path/to/config.php -p /var/run/db-replication.pid -d start\n```\n\n```php\n$config = require 'path/to/config.php';\n$replication = Replication::createFromConfig($config);\n\nwhile ([...]) {\n    [... some repetitive iteration, like writing thousands of records ...]\n    \n    $replication-\u003ethrottle();\n}\n```\n\nYour config file might look something like this:\n\n```php\n\u003c?php\n$config = [\n    // primary\n    'host'     =\u003e '10.0.0.1',\n    'username' =\u003e 'foo',\n    'password' =\u003e 'bar',\n    'replicas' =\u003e [\n        [\n            'host'     =\u003e '10.0.0.2',\n            'username' =\u003e 'foo',\n            'password' =\u003e 'bar',\n        ],\n    ],\n    'storage' =\u003e [\n        'class' =\u003e \\Phlib\\DbHelperReplication\\Replication\\Memcache::class,\n        'args'  =\u003e [[]],\n    ],\n];\n\nreturn $config;\n```\n\n## License\n\nThis package is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlib%2Fdb-helper-replication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphlib%2Fdb-helper-replication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlib%2Fdb-helper-replication/lists"}