{"id":20753788,"url":"https://github.com/repejota/phpnats","last_synced_at":"2025-05-16T07:06:33.554Z","repository":{"id":60774649,"uuid":"38102738","full_name":"repejota/phpnats","owner":"repejota","description":"A PHP client for the NATSio cloud messaging system.","archived":false,"fork":false,"pushed_at":"2023-03-28T11:17:25.000Z","size":360,"stargazers_count":235,"open_issues_count":24,"forks_count":99,"subscribers_count":13,"default_branch":"develop","last_synced_at":"2025-05-16T07:06:22.419Z","etag":null,"topics":["client","message-bus","message-queue","messaging","nats","php"],"latest_commit_sha":null,"homepage":"http://nats.io","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/repejota.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,"governance":null}},"created_at":"2015-06-26T09:28:49.000Z","updated_at":"2025-03-29T16:42:02.000Z","dependencies_parsed_at":"2022-10-04T15:46:23.968Z","dependency_job_id":"45689b38-d03b-4d30-8f1b-d4909a0e120f","html_url":"https://github.com/repejota/phpnats","commit_stats":{"total_commits":331,"total_committers":21,"mean_commits":"15.761904761904763","dds":0.5498489425981873,"last_synced_commit":"bd089ea66ef41f557830449872389750dd12a99f"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repejota%2Fphpnats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repejota%2Fphpnats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repejota%2Fphpnats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/repejota%2Fphpnats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/repejota","download_url":"https://codeload.github.com/repejota/phpnats/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485066,"owners_count":22078767,"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":["client","message-bus","message-queue","messaging","nats","php"],"created_at":"2024-11-17T09:14:51.013Z","updated_at":"2025-05-16T07:06:28.522Z","avatar_url":"https://github.com/repejota.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"phpnats\n=======\n\n**Travis**\n\n| Master  | Develop |\n| ------------- | ------------- |\n| [![Build Status](https://travis-ci.org/repejota/phpnats.png?branch=master)](https://travis-ci.org/repejota/phpnats)  | [![Build Status](https://travis-ci.org/repejota/phpnats.png?branch=develop)](https://travis-ci.org/repejota/phpnats)  |\n\n**Coverage**\n\n| Master  | Develop |\n| ------------- | ------------- |\n| [![Coverage Status](https://coveralls.io/repos/repejota/phpnats/badge.svg?branch=master)](https://coveralls.io/r/repejota/phpnats?branch=master) | [![Coverage Status](https://coveralls.io/repos/repejota/phpnats/badge.svg?branch=develop)](https://coveralls.io/r/repejota/phpnats?branch=develop)  |\n\nIntroduction\n------------\n\nA PHP client for the [NATS messaging system](https://nats.io).\n\nRequirements\n------------\n\n* php 5.6+\n* [gnatsd](https://github.com/apcera/gnatsd)\n\n\nUsage\n-----\n\n### Installation\n\nLet's start by downloading composer into our project dir:\n```\ncurl -O http://getcomposer.org/composer.phar\nchmod +x composer.phar\n```\n\nNow let's tell composer about our project's dependancies, in this case, PHPNats. The way we do this is by creating a composer.json file, and placing it in the root folder of our project, right next to composer.phar\n\n```\n{\n  \"require\": {\n    \"repejota/nats\": \"dev-master\"\n  }\n}\n```\nLet's let Composer work its magic:\n```\nphp composer.phar install\n```\nComposer will download all the dependencies defined in composer.json, and prepare all the files needed to autoload them.\n\n\n### Basic Usage\n\n```php\n$client = new \\Nats\\Connection();\n$client-\u003econnect();\n\n// Publish Subscribe\n\n// Simple Subscriber.\n$client-\u003esubscribe(\n    'foo',\n    function ($message) {\n        printf(\"Data: %s\\r\\n\", $message-\u003egetBody());\n    }\n);\n\n// Simple Publisher.\n$client-\u003epublish('foo', 'Marty McFly');\n\n// Wait for 1 message.\n$client-\u003ewait(1);\n\n// Request Response\n\n// Responding to requests.\n$sid = $client-\u003esubscribe(\n    'sayhello',\n    function ($message) {\n        $message-\u003ereply('Reply: Hello, '.$message-\u003egetBody().' !!!');\n    }\n);\n\n// Request.\n$client-\u003erequest(\n    'sayhello',\n    'Marty McFly',\n    function ($message) {\n        echo $message-\u003egetBody();\n    }\n);\n```\n\n### Encoded Connections\n\n```php\n$encoder = new \\Nats\\Encoders\\JSONEncoder();\n$options = new \\Nats\\ConnectionOptions();\n$client = new \\Nats\\EncodedConnection($options, $encoder);\n$client-\u003econnect();\n\n// Publish Subscribe\n\n// Simple Subscriber.\n$client-\u003esubscribe(\n    'foo',\n    function ($payload) {\n        printf(\"Data: %s\\r\\n\", $payload-\u003egetBody()[1]);\n    }\n);\n\n// Simple Publisher.\n$client-\u003epublish(\n    'foo',\n    [\n     'Marty',\n     'McFly',\n    ]\n);\n\n// Wait for 1 message.\n$client-\u003ewait(1);\n\n// Request Response\n\n// Responding to requests.\n$sid = $client-\u003esubscribe(\n    'sayhello',\n    function ($message) {\n        $message-\u003ereply('Reply: Hello, '.$message-\u003egetBody()[1].' !!!');\n    }\n);\n\n// Request.\n$client-\u003erequest(\n    'sayhello',\n    [\n     'Marty',\n     'McFly',\n    ],\n    function ($message) {\n        echo $message-\u003egetBody();\n    }\n);\n```\n\n\nDeveloper's Information\n-----------------------\n\n### Releases\n\n* [Latest stable](https://github.com/repejota/phpnats/tree/master)\n* [Latest dev](https://github.com/repejota/phpnats/tree/develop)\n\n* [PHPNats on Packagist](https://packagist.org/packages/repejota/nats)\n\n### Tests\n\nTests are in the `tests` folder.\nTo run them, you need `PHPUnit` and execute `make test-tdd`.\n\nWe also have a BDD test suite under the `spec` folder.\nTo run the suite, you need `PHPSpec` and execute `make test-bdd`.\n\nYou can also execute the all suites ( TDD + BDD ) with `make test`.\n\n### Code Quality\n\nWe are using [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer/docs)\nto ensure our code follow an high quality standard.\n\nTo perform an analysis of the code execute `make lint`.\n\nThere is currently three steps when we lint our code:\n\n* First we lint with php itself `php -l`\n* Then we lint with PSR2 standard\n* And finally we lint with a custom [ruleset.xml](https://github.com/repejota/phpnats/blob/feature/lint-squiz/ruleset.xml) that checks dockblocks and different performance tips.\n\n\nCreators\n--------\n\n**Raül Pérez**\n\n- \u003chttps://twitter.com/repejota\u003e\n- \u003chttps://github.com/repejota\u003e\n\nLicense\n-------\n\nMIT, see [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frepejota%2Fphpnats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frepejota%2Fphpnats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frepejota%2Fphpnats/lists"}