PHPackages                             kabudu/event-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. kabudu/event-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

kabudu/event-logger
===================

Event logger is a PHP based event logger library that makes it easy to collect and query events in your web application based on user or system actions.

v1.1.1(8y ago)3193Apache 2.0PHPPHP &gt;=5.6.0CI failing

Since Aug 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/kabudu/event-logger)[ Packagist](https://packagist.org/packages/kabudu/event-logger)[ RSS](/packages/kabudu-event-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Event logger library with support for multiple persistence strategies
=====================================================================

[](#event-logger-library-with-support-for-multiple-persistence-strategies)

[![Build Status](https://camo.githubusercontent.com/7ac6b4167f3f3500b2f00550d55027a781e803081ab6da3c271ce7e36f096931/68747470733a2f2f7472617669732d63692e6f72672f6b61627564752f6576656e742d6c6f676765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kabudu/event-logger) [![Coverage Status](https://camo.githubusercontent.com/be851f774b1f1897bdb7fd816f1b94336523a99b6e4905eddda946925de131ca/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b61627564752f6576656e742d6c6f676765722f62616467652e737667)](https://coveralls.io/r/kabudu/event-logger)

Event logger is a PHP based event logger library that makes it easy to collect and query events in your web application based on user or system actions.

With event logger you can:

- collect any kind of statistical data such as number of clicks for a certain url, page views, conversions or any kind of user generated action for your web application, API or mobile application
- collect and store human readable event logs such as: **Bob smith updated his email address on 12th January, 2015 at 12:30AM**
- collect and store human readable user notifications such as: **Bob Smith sent you a message on 12th January, 2015 at 12:30AM**
- collect and store system events, either human readable or not
- and any other sort of event logging your imagination allows you to come up with

Features
--------

[](#features)

- Collect any kind of event data

    `@see EventLogger\Event\EventInterface`
- Query and analyse the collected data
- Multiple persistence strategies (currently ships with an SQLite, MySQL and Null implementation)
- Extensible architecture
- Full test coverage with [phpunit](https://phpunit.de/)

Requirements
------------

[](#requirements)

- PHP 5.6.0+
- SQLite 3.0.7+ (required for the unit tests, you do not have to use the provided SQLite storage implementation)
- Optional but recommended: Composer

Getting Started
---------------

[](#getting-started)

The simplest way to work with event-logger is when it is installed as a Composer package in your application. Composer is not required, but it simplifies the usage of this library.

To find out more about Composer, please visit

a) Add event-logger to your applications composer.json file

```
// ...
"require": {
     "kabudu/event-logger": "1.x"  // The most recent tagged version
 },
// ...

```

Run `composer install`

b) Add the Composer autoload to your projects bootstrap file if you have not done so already. (example)

`require 'vendor/autoload.php';`

c) If you are not using Composer, simply download the package and copy the "src" folder into your project ensuring that your application can autoload the libraries classes

Log a Single Event
------------------

[](#log-a-single-event)

```
use EventLogger\Event\Event;
use EventLogger\Logger\Logger;
use EventLogger\Storage\SQLiteStorage;

// Initialise an SQLite database/table
$pdo = new \PDO('sqlite:my_event_log.sqlite');
$pdo->exec(sprintf("CREATE TABLE IF NOT EXISTS %s (
            id INTEGER PRIMARY KEY,
            type TEXT,
            sub_type TEXT DEFAULT NULL,
            target_type TEXT DEFAULT NULL,
            target_id INTEGER DEFAULT 0,
            message INTEGER DEFAULT NULL,
            data TEXT DEFAULT NULL,
            created TEXT DEFAULT '0000-00-00 00:00:00',
            action TEXT DEFAULT NULL,
            user TEXT DEFAULT NULL
        )",SQLiteStorage::TABLE_NAME));

// Create the storage strategy
$storage = new SQLiteStorage($pdo);

// Create the logger
$logger = new Logger($storage);

// Create an event
$event = new Event();
$event->setType('event');
$event->setSubType('pageview');
$event->setMessage('user [foo] viewed a page of interest to you');
$event->setData(array('[foo]' => 'bar'));
$event->setUser(2);

// Log the event
$logger->log($event);

```

Log Multiple Events
-------------------

[](#log-multiple-events)

```
use EventLogger\Event\Event;
use EventLogger\Logger\Logger;
use EventLogger\Storage\SQLiteStorage;
use EventLogger\Event\Collection\EventCollection;

// Initialise an SQLite database/table
$pdo = new \PDO('sqlite:my_event_log.sqlite');
$pdo->exec(sprintf("CREATE TABLE IF NOT EXISTS %s (
            id INTEGER PRIMARY KEY,
            type TEXT,
            sub_type TEXT DEFAULT NULL,
            target_type TEXT DEFAULT NULL,
            target_id INTEGER DEFAULT 0,
            message INTEGER DEFAULT NULL,
            data TEXT DEFAULT NULL,
            created TEXT DEFAULT '0000-00-00 00:00:00',
            action TEXT DEFAULT NULL,
            user TEXT DEFAULT NULL
        )",SQLiteStorage::TABLE_NAME));

// Create the storage strategy
$storage = new SQLiteStorage($pdo);

// Create the logger
$logger = new Logger($storage);

// Create an event
$event1 = new Event();
$event->setType('event');
$event->setSubType('pageview');
$event->setData(array('[foo]' => 'bar'));
$event->setUser(2);

// Create another event
$event2 = new Event();
$event->setType('event');
$event->setSubType('system');
$event->setMessage('A nominal value of [nominal] has been detected for the pressure release valve');
$event->setData(array('[nominal]' => '120'));

// create an event collection and add your events
$collection = new EventCollection();
$collection->addEvent($event1);
$collection->addEvent($event2);

// Log the events
$logger->log($collection);

```

Log an Event to Multiple Persistence Back-ends
----------------------------------------------

[](#log-an-event-to-multiple-persistence-back-ends)

**Note:** In a real world application you might have implemented your own persistence strategies, e.g. MongoDB, Elasticsearch, Google Cloud Datastore etc.

```
use EventLogger\Event\Event;
use EventLogger\Logger\Logger;
use EventLogger\Storage\SQLiteStorage;
use EventLogger\Storage\NullStorage;
use EventLogger\Logger\Collection\LoggerCollection;

// Initialise an SQLite database/table
$pdo = new \PDO('sqlite:my_event_log.sqlite');
$pdo->exec(sprintf("CREATE TABLE IF NOT EXISTS %s (
            id INTEGER PRIMARY KEY,
            type TEXT,
            sub_type TEXT DEFAULT NULL,
            target_type TEXT DEFAULT NULL,
            target_id INTEGER DEFAULT 0,
            message INTEGER DEFAULT NULL,
            data TEXT DEFAULT NULL,
            created TEXT DEFAULT '0000-00-00 00:00:00',
            action TEXT DEFAULT NULL,
            user TEXT DEFAULT NULL
        )",SQLiteStorage::TABLE_NAME));

// Create a storage strategy
$sqliteStorage = new SQLiteStorage($pdo);

// Create another storage strategy
$nullStorage = new NullStorage();

// Create a logger
$logger1 = new Logger($sqliteStorage);

// Create another logger
$logger2 = new Logger($nullStorage);

// Create a logger collection and add your loggers
$collection = new LoggerCollection();
$collection->addLogger($logger1);
$collection->addLogger($logger2);

// Create an event
$event = new Event();
$event->setType('event');
$event->setSubType('pageview');
$event->setMessage('user [foo] viewed a page of interest to you');
$event->setData(array('[foo]' => 'bar'));
$event->setUser(2);

// Log the event
$collection->log($event);

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~334 days

Total

3

Last Release

3245d ago

PHP version history (3 changes)1.0PHP &gt;=5.3.3

v1.1PHP &gt;=5.5.0

v1.1.1PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c190166185f78e7f1e5451da5093a82e6b98c133217f5cf18f99a530341480f?d=identicon)[kabudu](/maintainers/kabudu)

---

Top Contributors

[![kabudu](https://avatars.githubusercontent.com/u/3732230?v=4)](https://github.com/kabudu "kabudu (28 commits)")[![boxedcode](https://avatars.githubusercontent.com/u/32240781?v=4)](https://github.com/boxedcode "boxedcode (1 commits)")

---

Tags

eventloggingtrackingconversionmarketingstatistic

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kabudu-event-logger/health.svg)

```
[![Health](https://phpackages.com/badges/kabudu-event-logger/health.svg)](https://phpackages.com/packages/kabudu-event-logger)
```

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90334.6M36](/packages/bugsnag-bugsnag-laravel)[bugsnag/bugsnag

Official Bugsnag notifier for PHP applications.

56347.0M78](/packages/bugsnag-bugsnag)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[pragmarx/tracker

A Laravel Visitor Tracker

2.9k300.0k1](/packages/pragmarx-tracker)[bugsnag/bugsnag-symfony

Official BugSnag notifier for Symfony applications.

453.0M3](/packages/bugsnag-bugsnag-symfony)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
