1. Go to this page and download the library: Download appsignal/appsignal-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
appsignal / appsignal-php example snippets
use Appsignal\Appsignal;
// add a custom instrumentation span to the current trace
Appsignal::instrument('some_event', closure: fn() => sleep(1));
// add a custom instrumentation span to the current trace with data
Appsignal::instrument('some_event', ['region' => 'eu'], closure: fn() => sleep(1));
// customize the name of the trace
Appsignal::setAction('my action'),
// add attributes to the current span
Appsignal::addAttributes([
'string-attribute' => 'abcdef',
'int-attribute' => 1234,
'bool-attribute' => true,
]);
// add tags to the current span
Appsignal::addTags([
'string-tag' => 'some value',
'integer-tag' => 1234,
'bool-tag' => true,
]);
// report a handled exception
Appsignal::setError($exception);
// add metrics
Appsignal::setGauge('my_gauge', 12);
Appsignal::setGauge('my_gauge_with_attributes', 13, ['region' => 'eu']);
Appsignal::addDistributionValue('memory_usage', 50);
Appsignal::addDistributionValue('memory_usage', 70);
Appsignal::addDistributionValue('with_attributes', 10, ['region' => 'eu']);
Appsignal::addDistributionValue('with_attributes', 20, ['region' => 'eu']);
Appsignal::addDistributionValue('with_attributes', 30, ['region' => 'eu']);
Appsignal::incrementCounter('my_counter', 1);
Appsignal::incrementCounter('my_counter', 3, ['region' => 'eu']);
bash
composer
bash
composer test tests/Path/To/YourTest.php
# or with Docker
scripts/test tests/Path/To/YourTest.php
bash
PHP_VERSION=8.5 scripts/test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.