To connect your Symfony application to Palzin Monitor (APM), follow these steps.
Use the following command in your terminal to install the latest version of the Palzin Symfony bundle:
composer require palzin-apm/palzin-symfony
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.
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.
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.
It takes less than a minutes to setup your first monitoring.