Configuration

Customize the package behaviour.

As you could see in installation instructions, our package include a Configuration class that contains the options to customize the package's behaviour.

// Create a configuration instance.
$configuration = new Configuration('YOUR_API_KEY');
// Pass the configuration to the Inspector constructor.
$inspector = new Inspector($configuration);

You can use the following variables to determine how Inspector will collect information for your application:

Option

Type

Default

Description

api_key

string

Your application key to identify your project in Inspector.

enabled

boolean

true

Enable/Disable data transfer from your app to inspection API.

transport

string

sync

The way inspector send data to our inspection API.

$configuration = (new Configuration('YOUR_API_KEY'))
->setEnabled(true)
->setTransport('sync');

Transport

Inspector start to send data to the inspection API after your application has sent the response to the user. This guarantee optimal performance from your users point of view.

By default the package use php CURL extension to send data out of your server in a synchronous way. This means that after response has sent to the user, your application still working for a few milliseconds to accomplish data transfer, and your php engine can't close the execution if CURL isn't finished.

If your backend serves a huge amount of traffic you could prefer to execute data transfer in background (async) at server level and leave the php engine free to close its execution immediately. The package will run CURL from exec function, like a cli command, so data transfer is executed silently and your script will terminate immediately.

Async transport works only on UNIX based systems.

Although async is the most efficient way to send data, you will not be able to know if the transfer fails and why. Instead using the sync method the package records any failures in the apache logs for debugging purpose. Consider to start using sync method, and when your are sure that everything is working on your server you can switch to async.

You may active async transport setting to async the transport configuration option:

$configuration->setTransport('async');