Code Studio & Web IDE

Raw MD
Edit multi-file codebases in real-time with syntax highlighting, automatic linting, and zero deployment latency.

The In-Browser Cloud IDE

Botlify includes a full-featured web code editor located in Bot Studio → Code Editor. You can view, create, edit, and organize multiple files right from your browser or mobile device.

Key Studio Features

  • Multi-File Project Support: Create modular projects with helper files (e.g. includes/database.php, handlers/callback.php).
  • Real-Time Syntax Validation: Before saving, Botlify runs strict PHP syntax checks. If a parse or syntax error is found, it warns you immediately to prevent breaking live production webhooks.
  • Zero-Restart Hot Reloading: Changes saved to index.php are active immediately on the next incoming Telegram update. No server restarts or redeployment delays required!

Standard Starter Template Structure

index.php (Minimal Clean Template)
<?php
declare(strict_types=1);

// 1. Load Botlify Environment Variables
$envFile = __DIR__ . '/.env';
$ENV = [];
if (is_file($envFile)) {
    foreach (file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
        $line = trim($line);
        if ($line === '' || $line[0] === '#' || !str_contains($line, '=')) continue;
        [$k, $v] = explode('=', $line, 2);
        $ENV[trim($k)] = trim(trim($v), ""'");
    }
}

define('BOT_TOKEN', $ENV['BOT_TOKEN'] ?? '');
define('ADMIN_CHAT_ID', $ENV['ADMIN_CHAT_ID'] ?? '');

// 2. Fast Telegram API Dispatcher
function bot(string $method, array $params = []): array {
    $ch = curl_init('https://api.telegram.org/bot' . BOT_TOKEN . '/' . $method);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST           => true,
        CURLOPT_POSTFIELDS     => json_encode($params),
        CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
        CURLOPT_TIMEOUT        => 15
    ]);
    $res = curl_exec($ch);
    return json_decode((string)$res, true) ?: ['ok' => false];
}

// 3. Receive & Process Incoming Update
$update = json_decode((string)file_get_contents('php://input'), true);
if (!$update) exit('ok');

$msg = $update['message'] ?? null;
if ($msg && !empty($msg['text'])) {
    $chatId = $msg['chat']['id'];
    $text = trim($msg['text']);

    if ($text === '/start') {
        bot('sendMessage', [
            'chat_id'    => $chatId,
            'text'       => "👋 Hello! Your Botlify Cloud bot is live and responsive.",
            'parse_mode' => 'HTML'
        ]);
    }
}
exit('ok');