VigilmonHow to Monitor Your CodeIgniter Application with Vigilmon CodeIgniter is a lightweight PHP...
CodeIgniter is a lightweight PHP framework favored for its simplicity and small footprint. Despite being "the MVC framework for people who hate MVC frameworks," CodeIgniter powers thousands of production applications worldwide — many of them without any uptime monitoring.
This guide walks through adding robust monitoring to your CodeIgniter application with Vigilmon.
CodeIgniter apps are often deployed on shared hosting or VPS environments where:
Vigilmon monitors your endpoints every minute (or every 30 seconds on paid plans) and alerts you immediately when something breaks.
<?php
// application/controllers/Health.php
defined('BASEPATH') OR exit('No direct script access allowed');
class Health extends CI_Controller
{
public function index()
{
$this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => 'ok',
'timestamp' => time(),
'version' => CI_VERSION,
]));
}
public function deep()
{
$status = 'ok';
$checks = [];
// Check database
try {
$this->load->database();
$this->db->query('SELECT 1');
$checks['database'] = 'ok';
} catch (Exception $e) {
$checks['database'] = 'error';
$status = 'degraded';
}
http_response_code($status === 'ok' ? 200 : 503);
$this->output
->set_content_type('application/json')
->set_output(json_encode([
'status' => $status,
'checks' => $checks,
'timestamp' => time(),
]));
}
}
// application/config/routes.php
$route['health'] = 'health/index';
$route['health/deep'] = 'health/deep';
https://yourapp.com/health
CodeIgniter applications often rely heavily on scheduled tasks. Use Vigilmon heartbeat monitors:
<?php
// application/controllers/cli/Sync.php (CLI controller)
defined('BASEPATH') OR exit('No direct script access allowed');
class Sync extends CI_Controller
{
public function run()
{
// ... do your sync job ...
// Ping Vigilmon heartbeat to confirm job ran
$ch = curl_init('https://hb.vigilmon.online/your-heartbeat-id');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
echo 'Sync complete' . PHP_EOL;
}
}
# crontab -e
*/15 * * * * php /var/www/html/index.php cli/sync/run
If the cron job stops running, Vigilmon's heartbeat monitor alerts you within the configured window.
| Monitor Type | Endpoint/Config | Purpose |
|---|---|---|
| HTTP Monitor | /health |
App availability |
| HTTP Monitor | /health/deep |
App + DB connectivity |
| Heartbeat | Vigilmon heartbeat URL | Cron job liveness |
| Keyword Monitor | Your homepage | Detect content failures |
CodeIgniter's simplicity makes it fast to add monitoring. With Vigilmon, you get instant alerts, a public status page, and full response time tracking — all without managing infrastructure.