ritey/nginx-log-analyzer 问题修复 & 功能扩展

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

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

ritey/nginx-log-analyzer

Composer 安装命令:

composer require ritey/nginx-log-analyzer

包简介

Analyze/Parse Nginx log using php

README 文档

README

Latest Version on Packagist Software License Build Status StyleCI Coverage Total Downloads

Installation

composer require ritey/nginx-log-analyzer

Usage

<?php

declare(strict_types=1);

use Ritey\NginxLogAnalyzer\Parse;
use Ritey\NginxLogAnalyzer\NginxAccessLogFormat;
use Ritey\NginxLogAnalyzer\RegexPattern;

$file = new SplFileObject('access.log');
$line = $file->fgets();

$parse = new Parse(new NginxAccessLogFormat(), new RegexPattern());
$information = $parse->line($line);

var_dump($information):

class stdClass#16 (8) {
  public $remote_addr =>
  string(13) "182.76.202.33"
  public $remote_user =>
  string(1) "-"
  public $time_local =>
  string(26) "21/Oct/2019:06:52:00 +0000"
  public $request =>
  string(14) "GET / HTTP/1.1"
  public $status =>
  string(3) "404"
  public $bytes_sent =>
  string(3) "580"
  public $http_referer =>
  string(1) "-"
  public $http_user_agent =>
  string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
}

Configuration

Basically, Parse require two implementation:

  1. Format contract. There is getStringRepresentation() : string method.
  2. Pattern contract. There are build(Format $format) : string and getIdentifiers() : array methods.

Library already have built-in format support of default nginx access.log format which is:

$remote_addr - $remote_user [$time_local] "$request" $status $bytes_sent "$http_referer" "$http_user_agent"

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固