PHP clieant for

php, client, AppEnlight


App Enlight PHP Client

IMPORTANT: This library is under development. You can use it for productive application on your own risk!

PHP Client for AppEnlight (previously known as Errormator).

App Enlight main goal is to monitor your application. This API client for PHP provides an easy to use interface to send to App Enlight:

  • logs;
  • error reports;
  • slow requests (with metrics).



To install this API in your application copy all folders to a location accessible by your application. Then whenever you want to use the App Enlight PHP client you should use the namespace:

use AppEnlight;

Framework integrations

You can use this PHP client in any PHP application but it will require from you a little effort to integrate the client with your application. If you are using Yii frameworkyou are really lucky guy :) This PHP client is delivered with extension allowing to use client within Yii Framework with minimal effort. If you like to add support for other frameworks, please feel free to contact me.

Pass your application API key

The most important, before you initialize client, is to pass your private API key generated in App Enlight dashboard for your application. If you like, you can set the other settings to according to your needs. Note that you can ommit other settings and client will still work. Below example shows all available settings

    $settings = new \AppEnlight\Settings();
    return $settings;

Create client

Once settings are defined, you can pass them to client.

$client = new \AppEnlight\Client($settings);

Send log data

Once the client is created you need to decide what kind of information you would like to send. You can choose from two endpoints:

  • log,
  • reports.

First is very simple and is used to store logs comming from your application.

    use \AppEnlight\Endpoint\Logs;
    use \AppEnlight\Endpoint\Data\Log;

    $uuid = $client->getUUID();

    /* add just 1 log */
    $aeLog = new Log();
    $aeLog->setMessage("Test message");

Send repot data

You can send multiple reports within one request. Each report may consist different set of data. You can send information about slow calls including traceback, error information, etc.

Below example shows how to send simple report

    use \AppEnlight;
    use \AppEnlight\Endpoint;
    use \AppEnlight\Endpoint\Data;
    use \AppEnlight\Endpoint\Data\Report;

    //get client
    $client = new Client($settings);

    //prepare report detail data 
    $report = new Report();
    $report->setUsername('test user');
    $report->setMessage('Very serious error');
    $report->setRequestStats(new RequestStats());

    //analyse trace returned by exception
    $trace = $exception->getTrace();
    foreach($trace as $t) {
      $aeTrace = new Traceback();
      $aeTrace->setFile(isset($t['file']) ? $t['file'] : 'unknown');
      $aeTrace->setFn(isset($t['class']) ? "{$t['class']}->{$t['function']}" : $t['function']);
      $aeTrace->setLine(isset($t['line']) ? $t['line'] : 0);

    $report->setRequest(new Request(););

    $report->setError('Very dangerouse error');


Update from version 0.4 to 0.5

Note that API in version 0.5 has been changed comparing to version 0.4. Briefly, report grouping has been changed and since version 0.5 content of report_details became part of single report. For more details compare documentation Reports endpoint for version 0.4 with 0.5

Integration with Laravel5

  • Run php artisan vendor:publish --provider="AppEnlight\Laravel\ServiceProvider" to publish config (config/app-enlight.php)
  • Add AppEnlight\Laravel\ServiceProvider to your providers array in config/app.php
  • Add 2 lines in App\Exceptions\Handler to report function
    //Send error report to AppEnlight
    global $app;
    $app->make('AppEnlight\Laravel\ErrorHandler', $e);

the final function should look like this:

    public function report(Exception $e)
        //Send error report to AppEnlight
        global $app;
        $app->make('AppEnlight\Laravel\ErrorHandler', $e);

        return parent::report($e);


  • add documentation how to use extension in Yii;