Inspector
BlogTry for free
  • Concepts
    • Introduction
    • Metrics
    • Notification Channels
      • Email
      • Slack
      • Telegram
      • Microsoft Teams
      • Google Chat
      • Webhook
      • Discord
      • Pushover
      • PagerDuty
      • Twilio - SMS
    • Filtering Syntax
    • Alerts
    • Grouping Patterns
    • Custom Segments
    • Billing
    • AI Bug Fixer
  • Security and access
    • Access control
    • Two-factor authentication
    • Connected Devices
  • SDK
    • PHP
      • Installation & Set Up
      • Custom Segments
      • Exceptions Monitoring
      • Configuration
    • Laravel / Lumen
      • Upgrade Guide
      • Installation & Set-up
      • Http Requests Monitoring
      • Configuration
      • Exception Monitoring
      • Laravel Vapor
      • Laravel Octane
      • Laravel Nova Tool
      • Group by service name
    • Symfony
      • Installation
      • Configuration
      • Exception Monitoring
    • CodeIgniter
      • Installation
      • Configuration
      • Exception Monitoring
    • Drupal
    • Spring Boot
    • Slim
    • NodeJS
      • Configurations
      • Custom Segments
      • Exception monitoring
      • Autowiring
    • ExpressJs
    • Fastify
    • Python
    • Django
      • Installation & Set Up
      • Custom Segments
      • Error Monitoring
  • REST API
    • Authentication
    • Apps
    • Platforms
    • Transactions
    • Segments
    • Analytics
Powered by GitBook
On this page
  • Requirements
  • Install
  • Configure the Ingestion Key
  • Test & Deploy
  • Access the Inspector instance
  1. SDK
  2. Symfony

Installation

Connect your Symfony application to Inspector.

PreviousSymfonyNextConfiguration

Last updated 3 months ago

Requirements

  • PHP >= 7.2

  • Symfony ^4.4 | ^5.2 | ^6.x | ^7.x

Install

Type the command below in your terminal to install the latest version of the bundle:

composer require inspector-apm/inspector-symfony

Configure the Ingestion Key

Create the inspector.yaml configuration file in your config/packages directory, and put the ingestion_key field inside:

inspector:
    ingestion_key: '%env(INSPECTOR_INGESTION_KEY)%'

Add the new variable in your production env file:

INSPECTOR_INGESTION_KEY=xxxxxxxxxxxxxxxxxxx

You can obtain the ingestion_key creating a new project in your dashboard.

To learn more about environment variables configuration you can check the .

Test & Deploy

Execute the Symfony command below to check if your app is properly configured and can send data to inspector:

php bin/console inspector:test

Inspector will monitor many components by default:

  • HTTP requests

  • Console commands

  • SQL queries

  • Twig views rendering

  • Messenger Background Processes

But you have several configuration parameters to customize its behavior. Learn more in the next section.

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.

namespace App\Controller;

use Inspector\Inspector;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;

class ProductController
{
    /**
     * @Route("/invoice")
     */
    public function generateInvoice(Inspector $inspector, Request $request): Response
    {
        $pdf = $inspector->addSegment(function () {
            return $this->createPDF();
        }, 'file', 'Create Invoice PDF');

        return $pdf;
    }
}

Go to to explore your data.

Inspector
Symfony documentation
https://app.inspector.dev/