How to Use Palzin Monitor with Symfony Framework


The Symfony package for Palzin Monitor provides application performance monitoring capabilities for Symfony applications. It automatically instruments your Symfony application and records performance metrics related to HTTP requests, database queries, jobs, commands, and more. With this package, you can easily monitor and analyze the performance of your Symfony application.

Step 1: Create a Symfony Project

To get started, you need to create a new Symfony project. Follow these steps to create a Symfony project:

  1. Open a terminal or command prompt.

  2. Run the following command to create a new Symfony project using Composer:

    composer create-project symfony/website-skeleton my_project_name

    Replace my_project_name with the desired name for your project.

  3. Navigate to the project directory:

    cd my_project_name

Step 2: Install Palzin Monitor Symfony Package

Once you have created the Symfony project, you can install the Palzin Monitor Symfony package. Follow these steps to install the package:

  1. In the terminal, navigate to the project directory if you're not already there.

  2. Run the following command to install the Palzin Monitor Symfony package using Composer:

    composer require palzin-apm/palzin-symfony
  3. After the package installation is complete, proceed to the next step to configure Palzin Monitor.

Step 3: Configure Palzin Monitor

To configure Palzin Monitor in your Symfony application, follow these steps:

  1. Open the config/packages/palzin.yaml file.

  2. Add the following configuration options to the file:

        ingestion_key: '%env(PALZIN_APM_INGESTION_KEY)%'
        url: '%env(PALZIN_APM_URL)%'
        enabled: true
        unhandled_exceptions: true
        query: true
        query_bindings: true
            - '_wdt'
            - '_profiler'
            - '_profiler_home'
            # Add more URLs to ignore as needed
            - 'app:create-user'
            # Add more commands to ignore as needed

    Replace 'PALZIN_APM_INGESTION_KEY' and 'PALZIN_APM_URL' with your actual Palzin Monitor (APM) ingestion key and URL respectively.

Step 4: Enable Palzin Monitor Bundle

To enable the Palzin Monitor bundle in your Symfony application, follow these steps:

  1. Open the config/bundles.php file.

  2. Add the following line at the end of the file:

    return [
        // ...
        Palzin\Symfony\Bundle\PalzinBundle::class => ['all' => true],

Step 5: Start Monitoring

At this point, you have successfully installed and configured Palzin Monitor in your Symfony application. The monitoring will start automatically as the application executes.

Exception Monitoring

Palzin Monitor provides automatic monitoring of unhandled exceptions in your Symfony application. If you want to manually report an exception without blocking the execution of your code, you can use the following approach:

try {
    // Your code statements here...
} catch (LogicException $exception) {
    // Report an exception intentionally to collect diagnostics data

By reporting an exception, you can collect diagnostic data and be alerted in real-time if something goes wrong in your code. Subsequent occurrences

of the same exception will also be monitored.

Access the Palzin Monitor Instance

To access the Palzin Monitor instance in your application, you can inject it into your controller or service:

use Palzin\Palzin;

class MyController extends AbstractController
    private $palzin;

    public function __construct(Palzin $palzin)
        $this->palzin = $palzin;

    // ...

With the Palzin Monitor instance, you can utilize its methods to add custom segments, track transactions, and more.

Exception Details

When an exception is detected, you can view the code within the stack trace and monitor its frequency of occurrence for better investigation.

Make sure to monitor the Palzin Monitor dashboard for real-time alerts and performance insights related to your Symfony application.

By following these steps, you can successfully integrate Palzin Monitor with your Symfony Framework application and monitor its performance.

Last updated: 1 second ago

Want to get started with Palzin Monitor? We offer a no-strings-attached
15 days trial. No credit card required.

It takes less than a minutes to setup your first monitoring.