Firebase Logger

Firebase Logger is a simple firebase PHP logger package to monitor and save the users activities.

Installation

Use composer to install firebase-logger:
composer require khaledalam/firebase-logger

Preview

Usage

example.php

<?php
// PHP 7.1^
//error_reporting(0);

include_once './FirebaseLogger.php';

$serviceFile = __DIR__ . '/serviceAccountKey.json';
$databaseUri = 'https://{EDIT_THIS}.firebaseio.com';

$firebaseLogger = new FirebaseLogger([
    'service_account_key_json' => $serviceFile,
    'database_uri' => $databaseUri,
    'database_realtime_name' => 'Logger',
]);

if ($_POST['search'])
{
    echo "<h2>Log saved!</h2>";
    $data = [
        'action' => 'search action',
        'value' => $_POST['search'],
    ];
    $firebaseLogger->log($data);
}
?>

<center>
    <form action="./example.php" method="post">
        <input type="text" placeholder="search text" name="search">
        <input type="submit" value="search">
    </form>
</center>

Check the config section in README file and files on GitHub: https://github.com/khaledalam/firebase-logger

Packagist: https://packagist.org/packages/khaledalam/firebase-logger

Facebook Comments
Please follow and like us:

Leave A Reply