coderofsalvation/browser-stream 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coderofsalvation/browser-stream

Composer 安装命令:

composer require coderofsalvation/browser-stream

包简介

stream text to browser in realtime without using websockets or ajax.

README 文档

README

Stream text to browser in realtime without using websockets. Think simple text progressbars, logging, longrunning tasks, terminal output etc.

Usage

$ composer require coderofsalvation/BrowserStream 

and then

	<?php
		
		use coderofsalvation\BrowserStream;

		BrowserStream::enable();
		BrowserStream::put("loading");

		for( $i = 0; $i < 10; $i++ ){
			BrowserStream::put(".");
			sleep(1);
		}
	?>

Now go to your browser and you'll see 'loading' and dots being added every second OH MY! :)

anim.gif?2

Test it with curl like so:

$ curl -H "Accept: text/event-stream" -N -s "http://localhost/foo.php"

Apache Gzip == no worky

Usually apache gzips the output of php. This is not good if you want realtime output. Therefore disable apache gzip buffering in .htaccess for a particular (realtime streaming) url like so:

	RewriteRule ^(yoururl)$ $1 [NS,E=no-gzip:1,E=dont-vary:1]

License

BSD

统计信息

  • 总下载量: 300
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-08-14