{"id":19675819,"url":"https://github.com/progerxp/phiws","last_synced_at":"2025-02-27T05:41:43.299Z","repository":{"id":146023849,"uuid":"581836057","full_name":"ProgerXP/Phiws","owner":"ProgerXP","description":"Pure PHP WebSocket server/client implementation","archived":false,"fork":false,"pushed_at":"2023-04-01T06:57:21.000Z","size":149,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T04:25:26.744Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProgerXP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2022-12-24T14:20:58.000Z","updated_at":"2024-03-16T20:52:05.000Z","dependencies_parsed_at":"2023-04-11T15:46:19.914Z","dependency_job_id":null,"html_url":"https://github.com/ProgerXP/Phiws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgerXP%2FPhiws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgerXP%2FPhiws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgerXP%2FPhiws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProgerXP%2FPhiws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProgerXP","download_url":"https://codeload.github.com/ProgerXP/Phiws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240985487,"owners_count":19889101,"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-11T17:26:00.790Z","updated_at":"2025-02-27T05:41:43.275Z","avatar_url":"https://github.com/ProgerXP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phiws - Pure PHP WebSocket server/client implementation\n\n* Written from scratch in conformance with RFC 7692 and Errata\n* Plugin-based architecture with nearly 50 events for fine execution control\n* Standard plugins: reconnecting, limits, cookies, HTTP Auth, ping/pong, etc.\n* Support for connecting to server through SOCKS proxy ([Phisocks](https://github.com/ProgerXP/Phisocks))\n* Support for user WebSocket Extensions and Protocols\n* Built-in support for `permessage-deflate` Extension\n* Transparent Server-Sent Events backend with `Last-Event-ID` support\n* JavaScript interface blending native WebSocket and EventSource\n* Over 5000 lines of unit tests\n* No external dependencies\n* PHP 5.6 and up\n\n## Basic usage\n\nEnable logging to a file or console during development:\n\n```\nPhiws\\Logger::defaultMinLevel('info');\nPhiws\\Loggers\\InMemory::$dumpOnShutdown = true;\n```\n\nAdd some useful plugins:\n\n```\nPhiws\\BaseTunnel::globalPlugins(new Phiws\\Plugins\\AutoReconnect);\nPhiws\\BaseTunnel::globalPlugins(new Phiws\\Plugins\\UserAgent);\n```\n\nSpecify how to process incoming data:\n\n```\n$dpp = new Phiws\\Plugins\\DataProcessorPicker;\n$dpp-\u003eproc(Phiws\\DataProcessors\\BufferAndTrigger::class)-\u003ewhenIsText();\nPhiws\\BaseTunnel::globalPlugins($dpp);\nPhiws\\BaseTunnel::globalPlugins(new JsonData);\n\nclass JsonData extends Phiws\\StatefulPlugin {\n  function events() {\n    return ['bufferedFrameComplete'];\n  }\n\n  function bufferedFrameComplete($cx, $applicationData = null, $extensionData = null) {\n    $data = json_decode($applicationData-\u003ereadAll());\n    $data-\u003eHERO = 'WOrld!';\n    $cx-\u003equeueJsonData($data);\n    $cx-\u003egracefulDisconnectAndWait();\n  }\n}\n```\n\nStart a WebSocket server (accept connections from web browser's [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), Node.js' [ws](https://www.npmjs.com/package/ws), etc.):\n\n```\n$server = new Server(8888);\n// Add non-global plugins like this:\n$server-\u003eplugins()-\u003eadd(new Phiws\\Plugins\\GarbageCollector);\n// Enable data compression:\n$server-\u003eextensions()-\u003eadd(new Phiws\\Extensions\\PerMessageDeflate);\n// Echo messages as soon as they appear:\n$server-\u003elogger()-\u003eechoMode(true);\n$server-\u003estart();\n$server-\u003eloop();\n```\n\nConnect to a WebSocket server (such as to Node.js' `ws`):\n\n```\n$client = new Phiws\\Client;\n// Server and Client share a common base class with general-purpose methods:\n$client-\u003elogger()-\u003eechoMode(true);\n$addr = new Phiws\\ServerAddress('127.0.0.1', 8888);\n$addr-\u003esecure(true);\n$client-\u003econnect($addr);\n$client-\u003eloop();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogerxp%2Fphiws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogerxp%2Fphiws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogerxp%2Fphiws/lists"}