Download the PHP package spudley/apache-log-iterator without Composer

On this page you can find all versions of the php package spudley/apache-log-iterator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package apache-log-iterator

ApacheLogIterator

Version 2.1.0

A small PHP class intended to simplify the processing of Apache log files within a PHP program.

Version History

Requirements

ApacheLogIterator has been tested under PHP 5.3.

This class has no external dependencies.

Functionality

ApacheLogIterator is a parser that aims to make the reading of your Apache log file as simple and as efficient as possible.

It extends the SPLFileObject. Normal usage of the SPLFileObject would be to open a file and use a foreach() loop to load each line from the file in turn. The ApacheLogIterator class extends this, such that instead of simply returning the raw data as read from the file, it processes it into a structured array.

Because it's an iterator, you can loop through it using foreach() without having to load the whole file into memory. This is particularly useful because Apache log files can be very large. Only the current record is in memory at any given time.

In addition, ApacheLogIterator comes with a small helper class called ApacheLogFields. This defines the structure of the log records. If your Apache is configured to produce logs in a different format to the ones described in the code, you may override the ApacheLogFiles class to define your own log record format as required.

Filtering the output is trivial: Since it is an Iterator class, you can filter the output using PHP's built-in FilterIterator.

Example for Standard Apache Logs

$logFile = "/path/to/apache/log/file";
$logIterator = new ApacheLogIterator($logFile);
foreach ($logIterator as $logRecord) {
    print_r($logRecord); //do whatever you want to here with the output array.
}

Example for Apache Error Logs

$logFile = "/path/to/apache/log/error_file";
$logFields = new ApacheLogFields();
$logFields->regex = '/^\[(... ... \d\d \d\d:\d\d:\d\d \d\d\d\d)\] \[(error)\] \[.+ (.*)\] (.*,) (.*$)$/';         
$logFields->fieldArray = array(                                                                      
    'originalLogEntry',
    'logtime',
    'type',
    'remoteIP',                                                                                      
    'query',
    'referrer'                                                                                       
);
$logIterator = new ApacheLogIterator($logFile, $logFields);                                    
foreach ($logIterator as $logRecord) {
    print_r($logRecord); //do whatever you want to here with the output array.
}

The output array looks something like this:

array (
    'originalLogEntry' => '*** the full log record, in case you need it ***',
    'localServer' => 'yourservername',
    'remoteIP' => '192.168.1.1',
    'datetime' => '21/Jul/2012:15:10:54 +0100',
    'method' => 'GET',
    'status' => '200',
    'bytes' => '32611',
    'referrer' => 'http://www.referralurl.com/',
    'userAgent' => 'Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20100101 Firefox/13.0.1',
    'request' => array (
        'scheme' => 'http',
        'host' => 'mydomain.com',
        'path' => '/query.php',
        'query' => 'q=te57+1ng&submit=Search',
        'fullURL' => 'http://mydomain.com:/query.php?q=te57+1ng&submit=Search',
        'queryArgs' => array (
            'q' => 'te57 1ng',
            'submit' => 'Search',
        ),
    ),
)

Copyright and License

This class was written by Simon Champion. Copyright Simon Champion and Connection Services Ltd.

It is released under the General Public License version 3 (GPLv3); see COPYING.txt for full license text. Please contact me if you require alternative licensing arrangements.


All versions of apache-log-iterator with dependencies

PHP Build Version
Package Version
Requires php Version ^5.3.3 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spudley/apache-log-iterator contains the following files

Loading the files please wait ....