How to Monitor Your Symfony Application with Vigilmon
How to Monitor Your Symfony Application with Vigilmon Symfony is one of the most robust PHP frameworks available. This guide shows how to add uptime monitoring to your Symfony application using Vigilmon. Crea
How to Monitor Your Symfony Application with Vigilmon
Symfony is one of the most robust PHP frameworks available. This guide shows how to add uptime monitoring to your Symfony application using Vigilmon.
Create a Health Check Controller
Symfony makes it easy to build a health endpoint:
<?php
// src/Controller/HealthController.php
namespace AppController;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationJsonResponse;
use SymfonyComponentRoutingAnnotationRoute;
use DoctrineORMEntityManagerInterface;
use SymfonyContractsCacheCacheInterface;
class HealthController extends AbstractController
{
#[Route('/health', name: 'health_check', methods: ['GET'])]
public function check(
EntityManagerInterface $em,
CacheInterface $cache
): JsonResponse {
$checks = [];
$ok = true;
// Database check
try {
$em->getConnection()->executeQuery('SELECT 1');
$checks['database'] = 'ok';
} catch (Exception $e) {
$checks['database'] = 'error';
$ok = false;
}
// Cache check
try {
$item = $cache->getItem('health_probe');
$item->set('ok');
$cache->save($item);
$checks['cache'] = 'ok';
} catch (Exception $e) {
$checks['cache'] = 'error';
$ok = false;
}
return new JsonResponse(
['status' => $ok ? 'ok' : 'degraded', 'checks' => $checks],
$ok ? 200 : 503
);
}
}
Add the route to your config/routes.yaml if you prefer YAML:
health_check:
path: /health
controller: AppControllerHealthController::check
methods: [GET]
Using Symfony's Built-in Health Check Bundle
For production apps, use the runroom/health-check-bundle:
composer require runroom/health-check-bundle
It provides structured health checks for Doctrine, Mailer, Redis, and more.
Add to Vigilmon
- Sign up at vigilmon.online
- Click Add Monitor → enter your URL
- Set interval to 1 minute
- Configure email or Slack alerts
Vigilmon checks your endpoint every minute and alerts you within 30 seconds if it returns anything other than 2xx.
Monitoring Symfony Messenger
Symfony Messenger (queue workers) can stop silently. Add queue depth to your health check:
use SymfonyComponentMessengerTransportTransportInterface;
// Inject the transport and check pending message count
$counts = $transport->getMessageCount();
$checks['messenger_pending'] = $counts;
Why Vigilmon Over Self-Hosted?
- Zero infrastructure to maintain
- Monitors from multiple global locations
- Alerts via email, Slack, webhooks
- Free tier for up to 5 monitors
Get started at vigilmon.online — setup takes under 5 minutes.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.