DEV Community

Vigilmon
Vigilmon

Posted on

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.

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
        );
    }
}
Enter fullscreen mode Exit fullscreen mode

Add the route to your config/routes.yaml if you prefer YAML:

health_check:
    path: /health
    controller: AppControllerHealthController::check
    methods: [GET]
Enter fullscreen mode Exit fullscreen mode

Using Symfony's Built-in Health Check Bundle

For production apps, use the runroom/health-check-bundle:

composer require runroom/health-check-bundle
Enter fullscreen mode Exit fullscreen mode

It provides structured health checks for Doctrine, Mailer, Redis, and more.

Add to Vigilmon

  1. Sign up at vigilmon.online
  2. Click Add Monitor → enter your URL
  3. Set interval to 1 minute
  4. 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;
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)