1. Go to this page and download the library: Download huid/nginx-log-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class MyEntry implements Huid\NginxLogParser\LogEntryInterface
{
}
class MyEntryFactory implements \Huid\NginxLogParser\LogEntryFactoryInterface
{
public function create(array $data): \Huid\NginxLogParser\LogEntryInterface
{
// @TODO implement your code here to return a instance of MyEntry
}
}
$factory = new MyEntryFactory();
$parser = Huid\NginxLogParser\LogParser::createFromFilepath('your-nginx-conf-path/nginx.conf');
$parser->setFactory($factory);
$entry = $parser->parse('172.16.16.50 - - [02/Feb/2020:17:10:04 +0800] "GET /xxx/xxxx/xxxxx?xxx=day HTTP/1.1" 200 12416 [0.347] "http://www.baidu.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" "-"
');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.