Botlify Native PHP 8.2+ Runtime: Pure Zero-Dependency Architecture
Why Botlify Cloud Exclusively Runs Pure PHP 8.2+
Botlify Cloud is architected exclusively around the native PHP 8.2+ runtime. We intentionally do not run Python, Node.js, or heavyweight Composer dependencies. This architectural decision makes Botlify bots up to 10x faster, virtually immune to memory leaks, and capable of operating under high concurrency with only 2MB of RAM per execution.
Every Botlify bot runs on our pre-compiled, highly optimized PHP 8.2+ JIT/OPcache runtime with built-in extensions:
curl (HTTP/2), pdo_sqlite (WAL mode), json, mbstring, and openssl. Zero setup, zero composer install required!
PHP 8.2 vs Node.js vs Python Comparison
| Metric / Feature | Botlify Native PHP 8.2+ | Node.js (Express / Telegraf) | Python (aiogram / telebot) |
|---|---|---|---|
| RAM Usage per Bot | ~2 MB to 4 MB | ~60 MB to 150 MB | ~80 MB to 200 MB |
| Cold Start / Worker Latency | <1 ms (Instant) | ~150 ms to 400 ms | ~300 ms to 800 ms |
| Dependency Overhead | Zero (Native PHP extensions) | Heavy (500+ node_modules) | Heavy (pip packages & venvs) |
| Process Lifecycle | Stateless per-request isolation | Long-running event loop | Long-running event loop |
| Crash Resistance | One error never affects other users | Uncaught exception kills entire bot | Event loop crash kills entire bot |
Complete Native Pure PHP 8.2 Examples (Zero Composer)
Below are real-world, complete examples showing how to perform every essential bot function using only native PHP 8.2 features with zero external libraries:
1. Pure PHP Webhook Router (High Performance Match)
Using PHP 8's native match expression provides instantaneous, type-safe command routing:
<?php
declare(strict_types=1);
$raw = file_get_contents('php://input');
$update = json_decode((string)$raw, true);
if (!is_array($update)) exit('OK');
$message = $update['message'] ?? [];
$chatId = $message['chat']['id'] ?? 0;
$text = trim($message['text'] ?? '');
$cmd = explode(' ', $text)[0];
if ($chatId) {
match($cmd) {
'/start' => bot('sendMessage', ['chat_id' => $chatId, 'text' => '🚀 Botlify Native PHP Engine Online!']),
'/help' => bot('sendMessage', ['chat_id' => $chatId, 'text' => '📖 Use /start or /stats.']),
'/stats' => bot('sendMessage', ['chat_id' => $chatId, 'text' => '📊 Memory: ' . round(memory_get_usage(true)/1024/1024, 2) . ' MB']),
default => bot('sendMessage', ['chat_id' => $chatId, 'text' => "Received: " . htmlspecialchars($text), 'parse_mode' => 'HTML'])
};
}
exit('OK');
2. Native Multipart Media Uploads (CURLFile)
Upload photos, audio, videos, or documents directly from your bot directory without any external SDK or package:
<?php
declare(strict_types=1);
function sendBotDocument(int $chatId, string $filePath, string $caption = ''): array {
$token = getenv('BOT_TOKEN');
if (!is_file($filePath)) return ['ok' => false, 'error' => 'File not found'];
$ch = curl_init("https://api.telegram.org/bot{$token}/sendDocument");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'chat_id' => $chatId,
'document' => new CURLFile($filePath),
'caption' => $caption
],
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false
]);
$res = curl_exec($ch);
curl_close($ch);
return json_decode((string)$res, true) ?: [];
}
// Example usage: send backup database to admin
sendBotDocument(123456789, __DIR__ . '/database.db', '📦 Automated SQLite Database Backup');
3. Native SQLite 3 High-Concurrency WAL Engine
No MySQL server or credentials needed. Pure native PDO SQLite with WAL mode delivers thousands of reads/writes per second:
<?php
declare(strict_types=1);
function db(): PDO {
static $pdo = null;
if ($pdo === null) {
$pdo = new PDO('sqlite:' . __DIR__ . '/database.db', null, null, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_TIMEOUT => 5
]);
// 3 Critical Pragmas for Maximum Concurrency
$pdo->exec('PRAGMA journal_mode = WAL;');
$pdo->exec('PRAGMA synchronous = NORMAL;');
$pdo->exec('PRAGMA busy_timeout = 5000;');
}
return $pdo;
}
4. Native Telegram Stars (XTR) Payments in Pure PHP
Accept Telegram Stars payments natively with zero payment processor fees or composer libraries:
<?php
declare(strict_types=1);
$update = json_decode(file_get_contents('php://input'), true) ?: [];
// 1. Approve Pre-Checkout
if (!empty($update['pre_checkout_query'])) {
bot('answerPreCheckoutQuery', [
'pre_checkout_query_id' => $update['pre_checkout_query']['id'],
'ok' => true
]);
exit('OK');
}
// 2. Deliver Goods upon Payment
if (!empty($update['message']['successful_payment'])) {
$pay = $update['message']['successful_payment'];
$userId = $update['message']['from']['id'];
$stars = $pay['total_amount']; // 1 star = 1 XTR
bot('sendMessage', [
'chat_id' => $userId,
'text' => "🎉 Thank you for your {$stars} ⭐️ Stars payment!\n\nYour license key is active.",
'parse_mode' => 'HTML'
]);
exit('OK');
}