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)186511[1 issues](https://github.com/gemblue/PHPWebsocket/issues)MITPHPPHP ^7.0

Since May 14Pushed 5y 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 1w 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 37% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity40

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

2195d 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

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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