DOCUMENTATION

PHP

See the basic setup steps below to get started with the Logify Alert service:

Generate an API Key

The Logify Alert service uses unique identifiers – API keys – to register and monitor individual applications. You will use this key later when creating an instance of Logify Alert client in code.

  1. Log in to the Logify Alert website: logify.devexpress.com.

  2. Switch to the Applications tab and click Create New Application.

  3. Specify the application name and description, then click Create.

  4. The Applications tab will now display a new entry with an auto-generated API key.

Send Reports to Logify Alert

This section contains step-by-step instructions on how to set up your PHP application so that it reports unhandled exceptions to the Logify Alert service.

Note: Logify Alert supports PHP starting from version 5.4.

To set up your application, do the following.

Add the Logify Alert Client to the Application's Code

  1. Create a composer.json file in your project's root folder or use an existing one.

  2. Add the section below to the composer.json file.

    "require": { "devexpress/logify.alert.php": "dev-master" }

  3. Execute the following command:

    php composer.phar install

  4. Add require __DIR__ . '/vendor/autoload.php'; to your PHP project.

All classes in the library are wrapped in the DevExpress\Logify namespace. Apply the use operator as demonstrated below to get rid of long names in your code:

use DevExpress\Logify\LogifyAlertClient; use DevExpress\Logify\Core\Attachment;

For more information on the client API, refer to the PHP Client document.

  1. Copy the Logify folder to your PHP project.

  2. Use the code below to include the LoadHelper.php file to the PHP script you use to call the Logify API.

    require_once('/Logify/LoadHelper.php');

  3. Register the library autoloader by executing the following code:

    spl_autoload_register(array("DevExpress\LoadHelper", "LoadModule"));

All classes in the library are wrapped in the DevExpress\Logify namespace. Apply the use operator as demonstrated below to get rid of long names in your code:

use DevExpress\Logify\LogifyAlertClient; use DevExpress\Logify\Core\Attachment;

For more information on the client API, refer to the PHP Client document.

Modify the Application's Code

Logify Alert provides you with two main approaches used to send reports: automatic reporting and manual reporting.

  1. Automatic reporting. To command Logify Alert to automatically listen to uncaught exceptions and deliver crash reports, add the following code to your application's code. To initialize your application, use the API Key generated for it.

    use DevExpress\Logify\LogifyAlertClient; $client = LogifyAlertClient::get_instance(); $client->apiKey = 'SPECIFY_YOUR_API_KEY_HERE'; $client-> start_exceptions_handling();

    - or -

    Manual reporting. To catch and send exceptions manually, add the following code to your application's code. To initialize your application, use the API Key generated for it.

    use DevExpress\Logify\LogifyAlertClient; try { $client = LogifyAlertClient::get_instance(); $client->apiKey = 'SPECIFY_YOUR_API_KEY_HERE'; } catch (Exception $e) { $client->send($e); }

  2. Restart your application.

Once your application has been updated, log in to logify.devexpress.com to review and process incoming reports.

Terms of use Copyright © 2016-2019 Developer Express Inc.