Star us on GitHub
Star
Menu

Using highlight.io with PHP Frameworks

Learn how to set up highlight.io on your PHP backend.

1

Install the Highlight PHP SDK via Composer.

Add Highlight to your maven pom file.

composer require highlight/php-sdk
Copy
2

Initialize the Highlight PHP SDK.

Highlight.init() initializes the Highlight backend SDK.

use Highlight\SDK\Common\HighlightOptions; use Highlight\SDK\Highlight; $projectId = '<YOUR_PROJECT_ID>'; // Use only a projectId to bootstrap Highlight if (!Highlight::isInitialized()) { Highlight::init($projectId); } // Use a HighlightOptions instance to bootstrap Highlight $options = HighlightOptions::builder($projectId)->build(); if (!Highlight::isInitialized()) { Highlight::initWithOptions($options); } // Use a HighlightOptions instance prepped with a serviceName to bootstrap Highlight $options = HighlightOptions::builder($projectId)->serviceName('test-service-01')->build(); if (!Highlight::isInitialized()) { Highlight::initWithOptions($options); }
Copy
3

Verify your errors are being recorded.

Now that you've set up the Middleware, verify that the backend error handling works by consuming an error from traced code.

4

Record custom errors. (optional)

If you want to explicitly send an error to Highlight, you can use the Highlight.captureException() method.

use Highlight\SDK\Highlight; Highlight->captureException(new Exception('This is a test exception'));
Copy
5

Set up logging.

Start sending logs to Highlight! Follow the logging setup guide to get started.