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.
-
Log in to the Logify Alert website: logify.devexpress.com.
-
Switch to the Applications tab and click Create New Application.
-
Specify the application name and description, then click Create.
-
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
-
Create a composer.json file in your project's root folder or use an existing one.
-
Add the section below to the composer.json file.
"require": { "devexpress/logify.alert.php": "dev-master" }
-
Execute the following command:
php composer.phar install
-
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.
-
Copy the Logify folder to your PHP project.
-
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');
-
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.
-
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); }
-
Restart your application.
Once your application has been updated, log in to logify.devexpress.com to review and process incoming reports.
|
|