izumi-kun / yii2-longpoll
Implements long polling connection
Installs: 14 852
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 0
Open Issues: 1
Type:yii2-extension
pkg:composer/izumi-kun/yii2-longpoll
Requires
- php: ^8.1
 - ext-ctype: *
 - npm-asset/jquery-longpoll-client: 0.3.0
 - yiisoft/yii2: ~2.0.52
 
Requires (Dev)
- ext-curl: *
 - phpunit/phpunit: ~10.5.38
 - squizlabs/php_codesniffer: ^3.11
 - symfony/process: *
 - yiisoft/yii2-httpclient: ^2.0
 
This package is auto-updated.
Last update: 2025-10-31 07:21:12 UTC
README
Implements long polling AJAX mechanism.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist izumi-kun/yii2-longpoll
or add
"izumi-kun/yii2-longpoll": "~1.0.0"
to the require section of your composer.json.
Basic Usage
Controller
class SiteController extends Controller { public function actions() { return [ 'polling' => [ 'class' => LongPollAction::class, 'events' => ['eventId'], 'callback' => [$this, 'longPollCallback'], ], ]; } public function longPollCallback(Server $server) { $server->responseData = 'any data'; } }
View
LongPoll::widget([ 'url' => ['site/polling'], 'events' => ['eventId'], 'callback' => 'console.log', ]);
Model
\izumi\longpoll\Event::triggerByKey('eventId');
Example
https://github.com/Izumi-kun/yii2-longpoll-example
License
BSD-3-Clause