Intallation
Connect your Symfony application to Inspector.

Server requirements

    PHP >= 7.2
    Symfony ^4.4 | ^5.2

Install

Type the command below in your terminal to install the latest version of the bundle:
1
composer require inspector-apm/inspector-symfony
Copied!

Configure the Ingestion Key

Create the inspector.yaml configuration file in your config/packages directory, and put the ingestion_key field inside:
1
inspector:
2
ingestion_key: '%env(INSPECTOR_INGESTION_KEY)%'
Copied!
Add the new variable in your production env file:
1
INSPECTOR_INGESTION_KEY=xxx
Copied!
You can obtain the ingestion_key creating a new project in your Inspector dashboard.
To learn more about environment variables configuration you can check the Symfony documentation.

Test everything is working

Execute the Symfony command below to check if your app can send data to inspector correctly:
1
php bin/console inspector:test
Copied!
Go to https://app.inspector.dev/home to explore your data.

Access the Inspector instance

Inspector instance is binded in the Symfony service container. In your controller, you can type-hint an argument with the Inspector's class name to get a concrete Inspector instance.
1
namespace App\Controller;
2
3
use Inspector\Inspector;
4
use Symfony\Component\HttpFoundation\Response;
5
6
class ProductController
7
{
8
/**
9
* @Route("/products")
10
*/
11
public function list(Inspector $inspector): Response
12
{
13
$inspector->addSegment(function () {
14
sleep(1);
15
});
16
17
// ...
18
}
19
}
Copied!
Last modified 3mo ago