{"id":27198480,"url":"https://github.com/valtzu/php-websocket-stream-wrapper","last_synced_at":"2025-04-09T20:40:00.389Z","repository":{"id":189608262,"uuid":"680931405","full_name":"valtzu/php-websocket-stream-wrapper","owner":"valtzu","description":"PHP Stream wrapper for WebSocket protocol","archived":false,"fork":false,"pushed_at":"2023-08-20T22:42:09.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-08-21T00:33:35.421Z","etag":null,"topics":["php","streamwrapper","websocket","ws","wss"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/valtzu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-20T21:31:58.000Z","updated_at":"2023-08-21T00:33:38.190Z","dependencies_parsed_at":"2023-08-21T00:43:57.203Z","dependency_job_id":null,"html_url":"https://github.com/valtzu/php-websocket-stream-wrapper","commit_stats":null,"previous_names":["valtzu/php-websocket-stream-wrapper"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtzu%2Fphp-websocket-stream-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtzu%2Fphp-websocket-stream-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtzu%2Fphp-websocket-stream-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valtzu%2Fphp-websocket-stream-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valtzu","download_url":"https://codeload.github.com/valtzu/php-websocket-stream-wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248109547,"owners_count":21049333,"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","streamwrapper","websocket","ws","wss"],"created_at":"2025-04-09T20:39:59.469Z","updated_at":"2025-04-09T20:40:00.382Z","avatar_url":"https://github.com/valtzu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebSocket stream wrapper for PHP 8.1+\n\n## How to use\n\n```php\n\n// All http \u0026 tls options work like usual\n$context = stream_context_create([\n  'http' =\u003e [...],\n  'ssl' =\u003e [...],\n]);\n\n$socket = fopen('wss://ws.postman-echo.com/raw', 'r+', context: $context);\n\n// Non-blocking mode also supported!\n// stream_set_blocking($socket, false);\n\nfwrite($socket, 'Hello world');\necho \"Received: \", fread($socket, 128), PHP_EOL;\n\nfclose($socket);\n```\n\n## How it works internally\n\nTurns out even though you can't open `http` stream wrapper in write mode, you can still write into the socket. So here we use http/tls wrappers for handshake and after that just continue operating on the socket that's left open. See [WebsocketStreamWrapper.php](src/WebsocketStreamWrapper.php) for more.\n\n## Contributing\n\nAll contributions are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaltzu%2Fphp-websocket-stream-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaltzu%2Fphp-websocket-stream-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaltzu%2Fphp-websocket-stream-wrapper/lists"}