{"id":26848970,"url":"https://github.com/varspool/wrench","last_synced_at":"2025-05-15T01:09:06.642Z","repository":{"id":42857687,"uuid":"818840","full_name":"varspool/Wrench","owner":"varspool","description":"A simple PHP WebSocket implementation for PHP 7.1","archived":false,"fork":false,"pushed_at":"2022-03-26T15:13:34.000Z","size":1086,"stargazers_count":594,"open_issues_count":17,"forks_count":208,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-05-13T12:09:16.155Z","etag":null,"topics":["php","websockets","wrench"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varspool.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2010-08-05T09:23:31.000Z","updated_at":"2025-04-23T12:08:24.000Z","dependencies_parsed_at":"2022-08-24T14:34:35.589Z","dependency_job_id":null,"html_url":"https://github.com/varspool/Wrench","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varspool%2FWrench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varspool%2FWrench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varspool%2FWrench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varspool%2FWrench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varspool","download_url":"https://codeload.github.com/varspool/Wrench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254042,"owners_count":22039792,"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":["php","websockets","wrench"],"created_at":"2025-03-30T21:23:59.929Z","updated_at":"2025-05-15T01:09:01.627Z","avatar_url":"https://github.com/varspool.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- vim: set tw=79 sw=4 ts=4 et ft=markdown : --\u003e\n# Wrench\n## Simple WebSocket Client/Server for PHP\n\n* [![Latest Stable Version](https://poser.pugx.org/wrench/wrench/v/stable)](https://packagist.org/packages/wrench/wrench)\n* [![Latest Unstable Version](https://poser.pugx.org/wrench/wrench/v/unstable)](https://packagist.org/packages/wrench/wrench)\n* [![Build Status](https://secure.travis-ci.org/varspool/Wrench.png?branch=master)](http://travis-ci.org/varspool/Wrench)\n* Documentation: [wrench.readthedocs.org](http://wrench.readthedocs.org/en/latest/index.html)\n\nA simple websocket server and client package for PHP 7.1.\n\n## Installation\n\nThe library is PSR-4 compatible, with a vendor name of **Wrench**. It's available on Composer as `wrench/wrench`, so you\ncan:\n\n```sh\ncomposer require wrench/wrench ~3.0\n```\n\n## Usage\n\nThis creates a server on 127.0.0.1:8000 with one Application that listens for\nWebSocket requests to `ws://localhost:8000/echo` and `ws://localhost:8000/chat`:\n\n### Server\n```php\n/**\n * An example application, that just echoes the received data back to the connection that sent it\n */\n$app = new class implements \\Wrench\\Application\\DataHandlerInterface\n{\n    public function onData(string $data, \\Wrench\\Connection $connection): void\n    {\n        $connection-\u003esend($data);\n    }\n};\n\n// A websocket server, listening on port 8000\n$server = new \\Wrench\\BasicServer('ws://localhost:8000', array(\n    'allowed_origins' =\u003e array(\n        'mysite.com',\n        'mysite.dev.localdomain'\n    )\n));\n\n$server-\u003eregisterApplication('echo', $app);\n$server-\u003eregisterApplication('chat', new \\My\\ChatApplication());\n$server-\u003esetLogger($monolog); // PSR3\n$server-\u003erun();\n```\n### Client\n```php\n/**\n * A client side example, that sends a string and will receive the data back to the connection that sent it\n */\n$client = new Client('ws://localhost:8000, http://localhost:8000);\n$client-\u003econnect();\n$client-\u003esendData('hello');\n$response = $client-\u003ereceive()[0]-\u003egetPayload();\n$client-\u003edisconnect();\n```\n\n## Releases and Changelog\n\nSee the [CHANGELOG](CHANGELOG.md) for detailed information about changes between releases.\n\n### PHP5 Support\n\nThe latest major release dropped support for PHP versions prior to 7.1. If you need support for older versions of PHP,\nsee the 2.0 branch. The latest 2.0 branch release is 2.0.8. You can install it with:\n\n```\ncomposer require wrench/wrench ~2.0\n```\n\n## Developing\n\n* Run `./vendor/bin/phpcs` and fix any errors that you come across\n* Run `./vendor/bin/phpunit --exclude-group large,medium` for a fast test between changes\n\n## See Also\n\n- [Ratchet](https://github.com/cboden/Ratchet) an excellent Websocket layer for\n  React.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarspool%2Fwrench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarspool%2Fwrench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarspool%2Fwrench/lists"}