Download the PHP package kislayphp/socket without Composer
On this page you can find all versions of the php package kislayphp/socket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kislayphp/socket
More information about kislayphp/socket
Files in kislayphp/socket
Package socket
Short Description High-performance C++ PHP extension providing realtime socket transport for long-running PHP services
License Apache-2.0
Homepage https://github.com/KislayPHP/socket
Informations about the package socket
Kislay Socket
Kislay Socket is the realtime socket transport package for KislayPHP. It provides long-running socket communication with Engine.IO polling, WebSocket upgrade support, rooms, namespaces, and event callbacks.
The package keeps compatibility aliases for existing EventBus namespaces:
Kislay\\Socket\\*is the primary APIKislay\\EventBus\\*andKislayPHP\\EventBus\\*remain available as compatibility aliases (permanently — not just during a transitional version line)
Installation
PIE
Add to php.ini:
Build from source
Minimal Server
Public API
Kislay\\Socket\\Server
on(string $event, callable $handler): boolemit(string $event, mixed $data): boolemitTo(string $room, string $event, mixed $data): boollisten(string $host, int $port, string $path): boolclientCount(): introomCount(string $room): intonAuth(callable $handler): boolonWithAck(string $event, callable $handler): boolgetClients(): arraysetMaxPayload(int $bytes): boolsetThreads(int $n): bool— civetweb worker thread count; call beforelisten(). Defaults to 4 (envKISLAYPHP_SOCKET_THREADSoverrides). Matters for real concurrency: each long-polling connection occupies one worker thread for up toping_interval_mswhile waiting, so a server handling more concurrent long-polling clients than it has threads will queue behind whichever connections are already blocked.namespace(string $ns): Kislay\\Socket\\Namespace
Kislay\\Socket\\Socket
id(): stringjoin(string $room): boolleave(string $room): boolemit(string $event, mixed $data): boolreply(string $event, mixed $data): boolemitTo(string $room, string $event, mixed $data): bool
Behavior notes:
Server::emit()broadcasts to all connected clients.Socket::emit()sends only to the current client.Socket::reply()is an alias for per-client emit.listen()blocks until the server stops.
Configuration
Primary environment variables:
KISLAYPHP_SOCKET_PING_INTERVAL_MSKISLAYPHP_SOCKET_PING_TIMEOUT_MSKISLAYPHP_SOCKET_MAX_PAYLOADKISLAYPHP_SOCKET_CORSKISLAYPHP_SOCKET_ALLOW_UPGRADEKISLAYPHP_SOCKET_TRANSPORTSKISLAYPHP_SOCKET_AUTH_ENABLEDKISLAYPHP_SOCKET_AUTH_TOKENKISLAYPHP_SOCKET_AUTH_QUERY_KEYSKISLAYPHP_SOCKET_AUTH_HEADER_KEYSKISLAYPHP_SOCKET_THREADS— civetweb worker thread count, default 4 (seesetThreads()above)
Legacy KISLAYPHP_EVENTBUS_* and KISLAYPHP_AUTH_* environment variables are still accepted as fallbacks for migration compatibility.
Current Limits
- in-process single server runtime
- no durable message history
- no multi-node transport bridge in this package yet
- at this stage, treat it as the socket transport layer, not as a durable event platform
- do not load
sockettogether withcoreand/orgatewayin the same PHP process. All three vendor their own copy of civetweb and export non-static symbols likemg_start; on platforms linking extensions with-flat_namespace(notably macOS), combining any two of them risks one's compiled civetweb code silently shadowing another's, with no error - just undefined behavior up to and including crashes. Run socket as its own process (e.g. behind gateway, or alongside core's process rather than inside it).
Positioning
Use kislayphp/socket for:
- realtime browser or service socket connections
- rooms and namespaces
- request/response style live events
- transport-level event delivery
Use kislayphp/queue for:
- background jobs
- retries and DLQ
- worker/server queue processing
Use future higher-level EventBus semantics only for distributed event distribution, not for the socket transport package itself.