承接 php-extended/php-tail 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

php-extended/php-tail

最新稳定版本:8.0.10

Composer 安装命令:

composer require php-extended/php-tail

包简介

A smart way to tail files depending of the environment

README 文档

README

A smart way to tail files depending of the environment

coverage build status

Installation

The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.

  • Download composer.phar from their website.
  • Then run the following command to install this library as dependency :
  • php composer.phar php-extended/php-tail ^8

Usage

The basic usage of this library is as follows :

use PhpExtended\Tail\Tail;
use PhpExtended\Tail\TailException;

$filename = "/../path/to/my/file.ext";
$tail = new Tail($filename);

try
{
	// 10 is the number of lines you want
	// 200 is the average number of chars on each line (optional)
	// false is to force throwing exceptions (optional, use true if you want silent mode)
	$lines = $tail->smart(10, 200, false);
}
catch(TailException $e)
{
	// do something is case it fails
}

This library proposes 6 methods to tail a file, which can be more or less performant depending on the context. They each follow the same signature (see sample code above).

Those methods are :

  • naive : Loads the whole file into php, then retains only the last lines
  • cheat : Uses underlying unix tail -n function
  • single : Uses a signle byte buffer to read backwards the file
  • simple : Uses a fixed size buffer to read backwards the file
  • dynamic : Uses a dynamically sized buffer to read backwards the file
  • smart : Tries to choose the best among those five to be the fastest (recommanded)

This library is inspired from this specific stackoverflow topic.

License

MIT (See license file).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-05