{"id":21336804,"url":"https://github.com/dan-da/crdt-php","last_synced_at":"2025-07-28T12:16:28.846Z","repository":{"id":62502568,"uuid":"281522669","full_name":"dan-da/crdt-php","owner":"dan-da","description":"Some experimental crdt implemented in PHP.","archived":false,"fork":false,"pushed_at":"2020-09-04T23:16:37.000Z","size":202,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T02:18:51.045Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dan-da.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-07-21T23:04:25.000Z","updated_at":"2024-07-29T15:35:45.000Z","dependencies_parsed_at":"2022-11-02T12:02:14.820Z","dependency_job_id":null,"html_url":"https://github.com/dan-da/crdt-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dan-da/crdt-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fcrdt-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fcrdt-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fcrdt-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fcrdt-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-da","download_url":"https://codeload.github.com/dan-da/crdt-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fcrdt-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267514958,"owners_count":24100030,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-21T23:55:20.114Z","updated_at":"2025-07-28T12:16:28.818Z","avatar_url":"https://github.com/dan-da.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CRDT-PHP: CRDT experiments\n\nThis code was initially written to implement a prototype of the\n[bounded counter](\u003chttps://hal.inria.fr/hal-01248192/document\u003e) CRDT.\n\n### bounded counter\n\nSome articles about bounded counter:\n* [State based CRDTs: bounded counter](https://bartoszsypytkowski.com/state-based-crdts-bounded-counter/)\n* [Bounded Counters: maintaining numeric invariants with high availability\n](https://pages.lip6.fr/syncfree/attachments/article/59/boundedCounter-white-paper.pdf)\n\nThe bounded counter requires pn_counter crdt, which requires g_counter crdt,\nso those types are implemented as well.\n\n### tree\n\nNext, a prototype of a crdt tree algo has been added.\n\nReferences:\n* [A highly-available move operation for replicated trees and distributed filesystems](https://martin.kleppmann.com/papers/move-op.pdf)\n* [CRDT: The Hard Parts](https://martin.kleppmann.com/2020/07/06/crdt-hard-parts-hydra.html)\n* [Youtube Video: CRDT: The Hard Parts](\u003chttps://youtu.be/x7drE24geUw\u003e)\n\n## Installation\n\nYou will need PHP 7.0+ and [composer](https://getcomposer.org/).\n\nOn Ubuntu:\n\n```\napt-get install php composer\n```\n\nTo install as a standalone repo and run tests:\n\n```\n$ git clone https://github.com/dan-da/crdt-php \u0026\u0026 cd crdt-php\n$ composer install\n```\n\nTo use as a library in your own project:\n\n```\n$ mkdir -p \u003cproject\u003e \u0026\u0026 cd \u003cproject\u003e\n$ composer require dan-da/crdt-php:dev-master\n```\n\n## Testing\n\nFor b_counter, go into the `tests` directory and run `./tester.php`, like so:\n\n```\n$ ./tester.php \nRunning tests in b_counter...\nRunning tests in g_counter...\nRunning tests in pn_counter...\nRunning tests in v_clock...\n[pass] 1 == 1  |  b_counter: replica_1-\u003evalue() == 1\n[pass] 7 != 1  |  b_counter: replica_0-\u003evalue() != replica_1-\u003evalue()  [before merge]\n[pass] 7 != 2  |  b_counter: replica_0-\u003evalue() != replica_2-\u003evalue()  [before merge]\n[pass] 1 != 2  |  b_counter: replica_1-\u003evalue() != replica_2-\u003evalue()  [before merge]\n[pass] 10 == 10  |  b_counter: replicas 0 and 1 equal  [after merge]\n[pass] 10 == 10  |  b_counter: replicas 0 and 2 equal  [after merge]\n[pass] 10 == 10  |  b_counter: replica_0-\u003evalue() == 10  [after merge]\n[pass] 10 == 10  |  g_counter: replicas 0 and 1 equal\n[pass] 10 == 10  |  g_counter: replicas 0 and 2 equal\n[pass] 10 == 10  |  g_counter: replica_0-\u003evalue() == 10\n[pass] 6 == 6  |  pn_counter: replicas 0 and 1 equal\n[pass] 6 == 6  |  pn_counter: replicas 0 and 2 equal\n[pass] 6 == 6  |  pn_counter: replica_0-\u003evalue() == 6\n[pass] object == object  |  vclock: merge\n[pass] 5 == 5  |  vclock: merge_less_left(5)\n[pass] 6 == 6  |  vclock: merge_less_left(6)\n[pass] 7 == 7  |  vclock: merge_less_left(7)\n[pass] 5 == 5  |  vclock: merge_less_right(5)\n[pass] 6 == 6  |  vclock: merge_less_right(6)\n[pass] 7 == 7  |  vclock: merge_less_right(7)\n[pass] 1 == 1  |  vclock: merge_same_id(1)\n[pass] 1 == 1  |  vclock: merge_same_id(2)\n[pass] 1 == 1  |  vclock: merge_same_id(3)\n[pass] 1 == 1  |  vclock: ordering. a dominates\n[pass] 1 == 1  |  vclock: ordering. a dominates\n[pass] 1 == 1  |  vclock: ordering. a dominates\n[pass] 1 == 1  |  vclock: ordering. b dominates\n[pass] 1 == 1  |  vclock: ordering. b dominates\n[pass] 1 == 1  |  vclock: ordering. b dominates\n[pass] 1 == 1  |  vclock: ordering. concurrent\n[pass] 1 == 1  |  vclock: ordering. concurrent\n[pass] 1 == 1  |  vclock: ordering. concurrent\n[pass] 1 == 1  |  vclock: ordering. a dominates\n[pass] 1 == 1  |  vclock: ordering. a dominates\n[pass] 1 == 1  |  vclock: ordering. a dominates\n[pass] 1 == 1  |  vclock: ordering. b dominates\n[pass] 1 == 1  |  vclock: ordering. b dominates\n[pass] 1 == 1  |  vclock: ordering. b dominates\n[pass] 1 == 1  |  vclock: ordering. equal\n[pass] 1 == 1  |  vclock: ordering. equal\n[pass] 1 == 1  |  vclock: ordering. equal\n\n\n41 tests passed.\n0 tests failed.\n```\n\nFor `tree`, go into src and run `php tree.php`, like so:\n\n```\n$ php tree.php Usage: tree.php \u003ctest\u003e\n\n\u003ctest\u003e can be any of:\n  test_concurrent_moves\n  test_concurrent_moves_cycle\n  test_apply_ops_random_order\u003c/test\u003e\n```\n\n```\n$ php tree.php test_concurrent_moves\n\nInitial tree state on both replicas\n\n- /\n  - root\n    - a\n    - b\n    - c\n\nreplica_1 tree after move\n\n- /\n  - root\n    - b\n      - a\n    - c\n\nreplica_2 tree after move\n\n- /\n  - root\n    - b\n    - c\n      - a\n\nreplica_1 state matches replica_2 state after each merges other's change. conflict resolved!\n\n--replica_1 --\n\n- /\n  - root\n    - b\n    - c\n      - a\n\n--replica_2 --\n\n- /\n  - root\n    - b\n    - c\n      - a\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fcrdt-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-da%2Fcrdt-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fcrdt-php/lists"}