{"id":19826242,"url":"https://github.com/aternosorg/php-etcd","last_synced_at":"2025-05-01T14:31:04.769Z","repository":{"id":34034407,"uuid":"166148413","full_name":"aternosorg/php-etcd","owner":"aternosorg","description":"PHP gRPC client for etcd v3","archived":false,"fork":false,"pushed_at":"2024-01-29T11:24:52.000Z","size":123,"stargazers_count":24,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-08T10:30:38.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/aternos/etcd","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/aternosorg.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":"2019-01-17T02:45:04.000Z","updated_at":"2024-04-17T06:10:12.000Z","dependencies_parsed_at":"2023-02-13T20:45:31.492Z","dependency_job_id":null,"html_url":"https://github.com/aternosorg/php-etcd","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-etcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-etcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-etcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aternosorg%2Fphp-etcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aternosorg","download_url":"https://codeload.github.com/aternosorg/php-etcd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224262074,"owners_count":17282267,"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-11-12T11:09:51.152Z","updated_at":"2024-11-12T11:09:51.233Z","avatar_url":"https://github.com/aternosorg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP gRPC client for etcd v3\nFull and/or simplified client for [etcd](https://github.com/etcd-io/etcd) v3 using [gRPC](https://github.com/grpc/grpc/).\n\n### About\nThis library includes the generated gRPC classes from the `.proto` files in the etcd repository \nin the [grpc](grpc) folder. You can use the (more complicated) gRPC classes or the simpler [`Client`](src/Client.php)\nclass for basic functionality. There are currently only a few basic functions implemented in the \nClient class, so feel free to add more functions when you implement them with the gRPC classes and\ncreate a pull request.\n\n### Installation\nThe gRPC PHP extension has to be installed to use this library.\nSee [this](https://github.com/grpc/grpc/tree/master/src/php) for a full explanation.\n\n```bash\nsudo apt install php php-dev php-pear\nsudo pecl install grpc\n```\n\nAnd add `extension=grpc.so` to the `php.ini` file.\n\nThe `protobuf` extension is not necessary, because it's a dependency of this library, which you\ncan install using\n\n```bash\ncomposer require aternos/etcd\n```\n\n### Usage\n\n#### Client class\n```php\n\u003c?php\n\n$client = new Aternos\\Etcd\\Client();\n$client = new Aternos\\Etcd\\Client(\"localhost:2379\");\n$client = new Aternos\\Etcd\\Client(\"localhost:2379\", \"username\", \"password\");\n\n// currently implemented functions\n$client-\u003eput(\"key\", \"value\");\n$client-\u003eget(\"key\");\n$client-\u003edelete(\"key\");\n$client-\u003eputIf(\"key\", \"newValue\", \"valueToCompareWith\");\n$client-\u003edeleteIf(\"key\", \"valueToCompareWith\");\n\n// complex transaction example\n$leaseId = $client-\u003egetLeaseID(10);\n$putOp = $client-\u003egetPutOperation('key', 'someValueToPutOnSuccess', $leaseId);\n$getOp = $client-\u003egetGetOperation('key');\n// following compare checks for key existence\n$compare = $client-\u003egetCompare('key', '0', \\Etcdserverpb\\Compare\\CompareResult::EQUAL, \\Etcdserverpb\\Compare\\CompareTarget::MOD);\n// execute Put operation and return the key we stored, just return the key value if it already exists\n$txnResponse = $client-\u003etxnRequest([$putOp, $getOp], [$getOp], [$compare]);\n$result = $client-\u003egetResponses($txnResponse, 'response_range', true);\n// $result[0] contains \"someValueToPutOnSuccess\"\n```\n\n#### Sharded client\n```php\n\u003c?php\n\n$clients = [\n    new Aternos\\Etcd\\Client(\"hostA:2379\"),\n    new Aternos\\Etcd\\Client(\"hostB:2379\"),\n    new Aternos\\Etcd\\Client(\"hostC:2379\")\n];\n$shardedClient = new Aternos\\Etcd\\ShardedClient($clients);\n\n$shardedClient-\u003eput(\"key\", \"value\");\n$shardedClient-\u003eget(\"key\");\n```\n\n### Failover client\n\n- automatically and transparently fails-over in case etcd host fails \n```php\n\u003c?php\n\n$clients = [\n    new Aternos\\Etcd\\Client(\"hostA:2379\"),\n    new Aternos\\Etcd\\Client(\"hostB:2379\"),\n    new Aternos\\Etcd\\Client(\"hostC:2379\")\n];\n$failoverClient = new Aternos\\Etcd\\FailoverClient($clients);\n\n// set 60 seconds as a hold-off period between another connection attempt to the failing host \n// default is 120 seconds\n// failing host is being remembered within FailoverClient object instance \n$failoverClient-\u003esetHoldoffTime(60);\n$failoverClient-\u003eput(\"key\", \"value\");\n$failoverClient-\u003eget(\"key\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternosorg%2Fphp-etcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faternosorg%2Fphp-etcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faternosorg%2Fphp-etcd/lists"}