PHPackages                             reich/longpolling - 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. reich/longpolling

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

reich/longpolling
=================

An intuitive and clean way to write long-polling applications

v1.0(8y ago)1452MITPHPPHP &gt;=5.6.0

Since Mar 25Pushed 8y ago1 watchersCompare

[ Source](https://github.com/edenreich/Long-Polling)[ Packagist](https://packagist.org/packages/reich/longpolling)[ Docs](https://github.com/edenreich)[ RSS](/packages/reich-longpolling/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (4)Used By (0)

[![](https://camo.githubusercontent.com/310d1bd0262a0a5b75adf6e7a0e0f955135258a9a1f49dfca438ce6aa08fca83/68747470733a2f2f73372e706f7374696d672e63632f3731686b653175617a2f6c6f6e67706f6c6c696e672e6a7067)](https://camo.githubusercontent.com/310d1bd0262a0a5b75adf6e7a0e0f955135258a9a1f49dfca438ce6aa08fca83/68747470733a2f2f73372e706f7374696d672e63632f3731686b653175617a2f6c6f6e67706f6c6c696e672e6a7067)

Long-Polling
============

[](#long-polling)

A intuitive and clean way to write long-polling applications

Installation
============

[](#installation)

For the javascript module: Simply import src/js/LongPolling.js into your project and embed in the html

For the PHP file you can use composer:

```
composer require reich/longpolling
```

Usage
=====

[](#usage)

On the server side you need to listen for changes with the following code snippet:

```
\Reich\PHP\LongPolling::check(1000, function() {
	// we are inside a continuing loop,
	// return some data to the client.
	// Only if the data has been changed / modified
	// the client will recieve the changes.
});
```

Here we are checking every second for data changes, if the returned value was not changed, then nothing will happend. If the data infact changed, the client will recieve the new data.

On the client side using javascript we need to set a listener for recieving the changed data:

```

```

```
	(function(LongPolling) {

		LongPolling.get('server.php').subscribe(function(recipes) {
			var recipes = JSON.parse(recipes);

			var div = document.getElementById('recipes');
			var output = '';

			for (var recipe in recipes) {
				output += 'Recipe: '+recipe+', Price: '+recipes[recipe]+'';
			}

			div.innerHTML = output;
		});

	})(LongPolling);
```

Notes
=====

[](#notes)

This technik is used by many big platforms such as facebook, twitter and many other rich internet applications out there.

It is very simple concept, yet very powerful. Now our users do not need to refresh their browser for changes :)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~0 days

Total

2

Last Release

2972d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/388842e0ff6cf34c4321689d6761546f1f65dbf9f7ef2d2cfc0aabdd3fc02cf0?d=identicon)[edenreich](/maintainers/edenreich)

---

Top Contributors

[![edenreich](https://avatars.githubusercontent.com/u/16985712?v=4)](https://github.com/edenreich "edenreich (10 commits)")

---

Tags

socketswebsocketlong-pollinglongpollinglivestream

### Embed Badge

![Health badge](/badges/reich-longpolling/health.svg)

```
[![Health](https://phpackages.com/badges/reich-longpolling/health.svg)](https://phpackages.com/packages/reich-longpolling)
```

###  Alternatives

[cboden/ratchet

PHP WebSocket library

6.4k21.4M239](/packages/cboden-ratchet)[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k34.5M258](/packages/rmccue-requests)[ratchet/rfc6455

RFC6455 WebSocket protocol handler

23433.7M69](/packages/ratchet-rfc6455)[amphp/websocket-client

Async WebSocket client for PHP based on Amp.

1613.0M39](/packages/amphp-websocket-client)[amphp/websocket

Shared code for websocket servers and clients.

453.1M9](/packages/amphp-websocket)[plesk/ratchetphp

PHP WebSocket library

1865.9k2](/packages/plesk-ratchetphp)

PHPackages © 2026

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