PHP code example of branchonline / yii2-eventtracker
1. Go to this page and download the library: Download branchonline/yii2-eventtracker 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/ */
'eventtracker' => [
'class' => 'branchonline\eventtracker\EventTracker',
'types_config' => '', // Class extending EventTypes
'keys_config' => '', // Class extending StateKeys
'post_event_handler' => '' // Your handler class, implementing the PostEventInterface
]
// Log that MY_EVENT happened for the current user with the optional data.
Yii::$app->eventtracker->logEvent(EventTypes::MY_EVENT, ['optional' => "data"]);
// Log that the state of MY_KEY changed to ['x' => 100].
Yii::$app->eventtracker->logState(StateKeys::MY_KEY, ['x' => 100]);
// Get the events between 1 jan 2016 and 1 feb 2016 for user 1 and 2 of type MY_EVENT_1 or MY_EVENT_2.
Yii::$app->eventtracker->eventsBetween(
TrackerTime::fromUnixTimestamp(1451606400),
TrackerTime::fromUnixTimestamp(1454284800),
[1, 2],
[EventTypes::MY_EVENT_1, EventTypes::MY_EVENT_2]
);
// Get the state of MY_KEY_1 and MY_KEY_2 at 1 jan 2016.
Yii::$app->eventtracker->stateAt(
TrackerTime::fromUnixTimestamp(1451606400),
[StateKeys::MY_KEY_1, StateKeys::MY_KEY_2]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.