How pro-cms/phpnuxbill works
Project Type and Purpose
• PHPNuxBill is a full-stack, PHP-based ISP billing system integrating Mikrotik routers, FreeRadius, QR-code voucher generation, payment gateways, and notifications (SMS, WhatsApp, Telegram). It provides both admin and customer portals and supports plugins and multiple languages.
Key Directories & Architectural Patterns
• “system/”: Core MVC-like PHP application (bootloader, autoload, controllers, ORM).
• “ui/”: Presentation layer—TPL templates, JS/CSS assets, themes.
• “qrcode/”: Standalone QR-code library with caching.
• “admin/” & “pages_template/”: Installer and static page support.
• Configuration (“config.sample.php”), installer (“install/”), updater scripts.
• Cron jobs (“cron.php”, “cron_reminder.php”) for scheduled tasks (auto-renewal, reminders).
• Plugin extensibility (“system/plugin/”, “system/paymentgateway/”).
• Third-party PEAR2 libraries for Mikrotik API under “system/autoload/PEAR2/Net/RouterOS”.
Main Components
a. Web Clients
• Admin UI (browser → admin/index.php)
• Customer portal (browser → index.php)
b. Web Server & PHP Application
• Apache/Nginx + PHP 7.4+ interpreter
• Entry points (index.php, system/boot.php, system/api.php)
• Router/Dispatcher → Controllers → Models/ORM → Views (TPL in ui/ui/)
c. Core Services & Libraries
• ORM layer (system/orm.php) ↔ MySQL
• QRCode module (qrcode/) for voucher generation
• Mikrotik API client (PEAR2/Net/RouterOS) ↔ Mikrotik routers
• FreeRadius integration (SQL backend, radius scripts)
• Plugin and PaymentGateway managers (dynamic loading under system/plugin & system/paymentgateway)
• Notification services (SMS gateway via PHP-CURL, Telegram BOT API, WhatsApp API)
d. Scheduled Jobs
• Cron processes for auto-renewal, reminder emails/SMS
e. External Systems
• MySQL database
• Mikrotik devices
• FreeRadius server + radius SQL schema
• Payment provider endpoints (e.g., PayPal, bank APIs)
• SMS / WhatsApp / Telegram servers
f. Data & File Storage
• File uploads (system/uploads/)
• Caches (system/cache/, ui/cache/, qrcode/cache/)
Relationships & Data Flow
• Client → Web server (HTTP request)
• Web server → Router/Dispatcher → Controller → Model → DB ←→ ORM
• Controller → View → Client (HTML/JSON)
• Voucher generation request → QRCode lib → qrcode/cache → image output
• Controller calls Mikrotik API client → RouterOS devices (TCP)
• Controller writes to FreeRadius SQL tables → FreeRadius server
• Cron jobs → PHP scripts → DB and external services
• Notification modules → External APIs (SMS, Telegram, WhatsApp)
• Plugin manager dynamically loads plugin code and hooks into controllers/services
• Payment gateway modules ↔ External payment provider APIs
Architectural Patterns & Principles
• MVC-style separation: Controllers (system/controllers), Models (ORM + autoload classes), Views (ui/ui/*.tpl).
• Dependency injection via autoloader (system/autoload/).
• Plugin architecture: Hookers in autoload, plugin manager loads extensions.
• Layered design: Presentation (ui/), Business logic (controllers/services), Data access (ORM), Integration adapters (Mikrotik, Payment, Notification).
• Cron-based scheduled tasks separate from HTTP flow.
Essential Details to Capture
• Entry points: index.php → boot.php → dispatcher (controllers)
• Autoload mechanism loading classes under system/autoload/
• Core controller modules (e.g., order, voucher, customer, router)
• Dynamic plugin and payment-gateway loading
• QRCode module with cache layer
• Cron processes and their interactions with core services
• Notification subsystems