Symfony Commands Monitoring

By Jérôme Vieilledent, on Dec 22, 2021

Blackfire Monitoring provides the ability to trace web requests and CLI commands. This is particularly useful when your application is using consumers, e.g. using Symfony Messenger or Laravel Horizon, but also in the case of commands you may run as cron jobs.

Introducing Symfony CLI Commands Integration

The Blackfire PHP SDK v1.28.0 provides a new seamless integration with Symfony CLI Commands. With this integration, you may now monitor cron jobs commands without even thinking about it!

All you need to do is to make your command classes implement the Blackfire\Bridge\Symfony\MonitorableCommandInterface interface. This way, these commands would be auto-traced, and a transaction name would be generated after the command name:

namespace App\Command;

use Blackfire\Bridge\Symfony\MonitorableCommandInterface;
use Symfony\Component\Console\Command\Command;

class UpdateSightingScoresCommand extends Command implements MonitorableCommandInterface
    protected static $defaultName = 'app:update-sighting-scores';

In the example above, the transaction would be named app:update-sighting-scores.

Start a Blackfire Monitoring subscription today!

Happy cron job Monitoring!

Jérôme Vieilledent

As a Developer Advocate, Jérôme is all about spreading the love! His technical/development background enable him to talk as a peer to peers with our developer users. You’ll read his tips and advices on performance management with Blackfire. And he’ll support you as a day-to-day user.