PHPackages                             gemblue/php-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. gemblue/php-websocket

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

gemblue/php-websocket
=====================

Simple websocket library for learning purpose

0.0.1(6y ago)186611[1 issues](https://github.com/gemblue/PHPWebsocket/issues)MITPHPPHP ^7.0

Since May 14Pushed 6y ago3 watchersCompare

[ Source](https://github.com/gemblue/PHPWebsocket)[ Packagist](https://packagist.org/packages/gemblue/php-websocket)[ RSS](/packages/gemblue-php-websocket/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHPWebsocket
============

[](#phpwebsocket)

Simple PHP Websocket Library / Server for Fun. Just making a wrapper from PHP Socket API. Modifying source code from reference and making simple OOP for a clean code.

Dependency
----------

[](#dependency)

PHP Socket Library

Install
-------

[](#install)

Create a exercise folder. Open it and run composer require.

```
composer require gemblue/php-websocket

```

Run Server
----------

[](#run-server)

- Make server file executable

```
sudo chmod +x ./vendor/gemblue/php-websocket/bin/server

```

- Run websocket server with port option

```
./vendor/gemblue/php-websocket/bin/server port:3000

```

Then it will show success output like

```
Listening incoming request on port 3000 ..

```

Prepare client.
---------------

[](#prepare-client)

Create a HTML file for websocket client, for example `index.html` :

```

		Nama

		Pesan

	Send

	function showMessage(messageHTML) {
		$('#output').append(messageHTML);
	}

	$(document).ready(function(){
		var websocket = new WebSocket("ws://127.0.0.1:3000");
		websocket.onopen = function(event) {
			showMessage("Berhasil masuk room ..");
		}
		websocket.onmessage = function(event) {
			var Data = JSON.parse(event.data);
			showMessage(""+Data.message+"");
			$('#message').val('');
		};

		websocket.onerror = function(event){
			showMessage("Problem due to some Error");
		};
		websocket.onclose = function(event){
			showMessage("Connection Closed");
		};

		$('#btn-send').on("click",function(event){
			event.preventDefault();
			var messageJSON = {
				name: $('#name').val(),
				message: $('#message').val()
			};
			websocket.send(JSON.stringify(messageJSON));
		});
	});

```

Open `index.html` with your browser. Use 2 tab/browser for simulation. Output will be like this :

[![Sample](https://camo.githubusercontent.com/2a3c4a2c1b1712a850734f4ba2726dd48eda75517173a09c5bb4f251418acb38/68747470733a2f2f692e6962622e636f2f504767483876792f73637265656e73686f742d6962622d636f2d323032302d30352d31342d31392d31372d33382e706e67)](https://camo.githubusercontent.com/2a3c4a2c1b1712a850734f4ba2726dd48eda75517173a09c5bb4f251418acb38/68747470733a2f2f692e6962622e636f2f504767483876792f73637265656e73686f742d6962622d636f2d323032302d30352d31342d31392d31372d33382e706e67)

Reference
---------

[](#reference)

-
-
-

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2242d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c2000ffb9f44643b83d90b1afc3bef6e9a50285b7ccf888fa3ee59c2b02bfba?d=identicon)[gemblue](/maintainers/gemblue)

---

Top Contributors

[![gemblue](https://avatars.githubusercontent.com/u/879313?v=4)](https://github.com/gemblue "gemblue (32 commits)")

---

Tags

php-socketphp-websocketsocket-programmingwebsocket

### Embed Badge

![Health badge](/badges/gemblue-php-websocket/health.svg)

```
[![Health](https://phpackages.com/badges/gemblue-php-websocket/health.svg)](https://phpackages.com/packages/gemblue-php-websocket)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M92](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
