PHPackages                             yaknet/websocket - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. yaknet/websocket

ActiveLibrary[HTTP &amp; Networking](/categories/http)

yaknet/websocket
================

A lightweight, pure PHP WebSocket server and client adapter implementing RFC 6455.

v1.2.5(2w ago)03MITPHPPHP &gt;=8.2

Since May 30Pushed 2w agoCompare

[ Source](https://github.com/y-packages/websocket)[ Packagist](https://packagist.org/packages/yaknet/websocket)[ RSS](/packages/yaknet-websocket/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

YakNet WebSocket Component
==========================

[](#yaknet-websocket-component)

[![PHP Version Support](https://camo.githubusercontent.com/79ac6c4536a3331e3d827319dd782adf525bdd6289ee5748a7023086c9ed0930/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d626c75652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yaknet/websocket)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan Analysis](https://camo.githubusercontent.com/95ad671a386caa3fc96a820cfdd0797d0094138dddcf57ce117e8cf8a568bc81/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323035253230636c65616e2d707572706c652e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![Tests Status](https://camo.githubusercontent.com/937e105fc83966d970d459cb02a1c3da1ba44f5e9522992176e869fce65b8a52/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpunit.de/)

A zero-dependency, lightweight, high-performance **WebSocket Server and Client** component for PHP applications. Designed with a non-blocking, multiplexed event-loop (`stream_select`) architecture, it enables seamless full-duplex real-time communication without external platform runtimes.

---

Features
--------

[](#features)

- **⚡ Zero External Dependencies:** Pure PHP implementation utilizing native PHP streams (`stream_socket_server`, `stream_socket_client`).
- **🔄 Event-Driven &amp; Non-Blocking:** High-performance single-threaded multiplexing using `stream_select`. Handles multiple concurrent clients efficiently.
- **🛡️ RFC 6455 Compliant:** Complete protocol coverage including el-sıkışma (handshake), fragment buffering, masking/unmasking, and close handshakes.
- **🔌 Built-in Client &amp; Server:** Contains both an event-driven Socket Server and a versatile Socket Client.
- **🔒 SSL/TLS Ready:** Native support for Secure WebSockets (`wss://`) through standard context configurations.
- **💓 Automatic Heartbeats:** Automated Ping-Pong frame handling, ensuring active connection tracking out of the box.
- **🎛️ Clean Adapter Contract:** Interface-driven connection handlers make it trivial to integrate with your existing codebase.

---

Installation
------------

[](#installation)

Add this package to your project using Composer (ensure your local repository mapping is configured):

```
composer require yaknet/websocket
```

---

Quick Start
-----------

[](#quick-start)

### 1. Create a Connection Handler

[](#1-create-a-connection-handler)

To process WebSocket events, implement the `ConnectionHandlerInterface`:

```
