承接 mvar/log-parser 相关项目开发

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

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

mvar/log-parser

最新稳定版本:v1.1.0

Composer 安装命令:

composer require mvar/log-parser

包简介

Universal log parser

README 文档

README

Latest Stable Version Build Status Code Coverage Code Quality

This library allows you to easily iterate over your Apache, nginx or any other web server log files.

Main features:

  • Log file iterator
  • Parser abstraction to help you implement your custom parser
  • Low memory footprint even with huge files

Installation

This library can be found on Packagist. The recommended way to install this is through Composer:

composer require mvar/log-parser:^1.0

Basic Usage

Lets say you have log file my.log with following content:

GET /favicon.ico 200 GET /about 404 

All you need to do to iterate over the file is to initialize SimpleParser with your regular expression and pass it to LogIterator:

<?php require __DIR__ . '/vendor/autoload.php'; use MVar\LogParser\LogIterator; use MVar\LogParser\SimpleParser; // Pass your regular expression $parser = new SimpleParser('/(?<method>\S+)\s+(?<path>\S+)\s+(?<response_code>\d+)/'); foreach (new LogIterator('my.log', $parser) as $data) { var_export($data); echo "\n"; }

The above example will output:

array ( 'method' => 'GET', 'path' => '/favicon.ico', 'response_code' => '200', ) array ( 'method' => 'GET', 'path' => '/about', 'response_code' => '404', )

It is also possible to parse compressed files by adding stream wrapper before file name:

$logFile = 'compress.zlib://file:///path/to/log.gz';

How To

Implemented Parsers

License

This package is licensed under the MIT License. See the LICENSE file for details.

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固