PHP code example of excimetry / symfony-excimetry

1. Go to this page and download the library: Download excimetry/symfony-excimetry library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

excimetry / symfony-excimetry example snippets



// config/packages/excimetry.php
return [
    'excimetry' => [
        // Whether the bundle is enabled
        'enabled' => true,

        // The sampling period in seconds
        'period' => 0.01,

        // The profiling mode (wall or cpu)
        'mode' => 'wall',
    ],
];


class Kernel extends BaseKernel
{
   ... 
   
    private ?ExcimetryService $excimetryService;

    public function boot(): void
    {
        if (!$this->booted) {
            // Start the profiler before booting the kernel
            if ($this->container && $this->container->has(ExcimetryService::class)) {
                $this->excimetryService = $this->container->get(ExcimetryService::class);
            }

           ...
        }
    }

    public function terminate(Request $request, Response $response): void
    {
        if (!is_null($this->excimetryService)) {
            $log = $this
                ->excimetryService
                ->stop()
                ->getExcimetry()
                ->getLog();
            
            $exporter = new PyroscopeBackend(
                serverUrl: 'https://pyro:4040',
                appName: 'symfony_app',
                exporter: new CollapsedExporter()
            );
            
            $exporter->send($log);
        }

        ...
    }
}