Symfony Installation

Installation

To connect your Symfony application to Palzin Monitor (APM), follow these steps.

Requirements

  • PHP version 7.2 or higher
  • Symfony version 4.4 or higher

Install

Use the following command in your terminal to install the latest version of the Palzin Symfony bundle:

composer require palzin-apm/palzin-symfony

Configure the Ingestion Key

Create a configuration file named palzin.yaml in the config/packages directory. Inside the file, add the ingestion_key field:

palzin:
  ingestion_key: '%env(PALZIN_APM_INGESTION_KEY)%'
  url: '%env(PALZIN_APM_URL)%'

Next, add the new variables in your production environment file:

PALZIN_APM_INGESTION_KEY=xxx
PALZIN_APM_URL=xxx

You can obtain the ingestion_key and url by creating a new project in your Palzin Monitor (APM) dashboard.

To learn more about configuring environment variables, you can refer to the Symfony documentation.

Test if everything is working

Execute the following Symfony command to verify if your application can successfully send data to Palzin Monitor (APM):

php bin/console palzin:test

Visit Palzin Monitor (APM) to explore your data.

Accessing the Palzin Monitor (APM) Instance

The Palzin Monitor (APM) instance is available in the Symfony service container. In your controller, you can use dependency injection to access an instance of the Palzin class.

namespace App\Controller;

use Palzin\Palzin;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class ProductController
{
    /**
     * @Route("/products")
     */
    public function list(Palzin $palzin): Response
    {
        $palzin->addSegment(function () {
            sleep(1);
        }, 'example-type');

        // ...
    }
}

By type-hinting the $palzin argument with the Palzin class, you can get a concrete instance of the Palzin Monitor (APM) in your controller.

Last updated: 8 months 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.