Version 5.0.0 — Desktop PHP applications with Electron.
MiPhant is a desktop application runner that lets you build and run PHP applications as native desktop apps on Linux and Windows. It combines Electron with a built-in HTTPS server that executes PHP through the FastCGI protocol, using platform-native PHP runtimes.
- Cross-platform: Linux (PHP-FPM) and Windows (PHP-CGI)
- Built-in HTTPS server with auto-generated self-signed certificates
- FastCGI protocol for PHP execution with persistent process management
- MiPhantLibs: PHP library for config, i18n, file operations, dialogs, routing and more
- Dark design system with CSS variables and responsive components
- System tray, notifications, dialogs, multi-window support
- i18n with automatic language detection and fallback chain
- Static PHP binary compiled via static-php-cli
- 17+ demo pages showcasing all features
┌──────────────────────────────────────────────────────────┐
│ Electron │
│ ┌───────────────┐ ┌──────────────────────────────┐ │
│ │ BrowserWindow │ │ Main Process │ │
│ │ (Renderer) │◄──►│ (Node.js) │ │
│ │ preload.js │IPC │ │ │
│ └───────────────┘ │ ┌────────────────────────┐ │ │
│ │ │ HTTPS Server │ │ │
│ │ │ (Node.js + TLS) │ │ │
│ │ └───────────┬────────────┘ │ │
│ │ │ FastCGI │ │
│ │ ┌───────────▼────────────┐ │ │
│ │ │ Linux: php-fpm │ │ │
│ │ │ Windows: php-cgi.exe │ │ │
│ │ │ (static binary) │ │ │
│ │ └────────────────────────┘ │ │
│ └──────────────────────────────┘ │
└──────────────────────────────────────────────────────────┘
- Renderer Process: Runs the PHP application output (HTML/CSS/JS)
- Preload Bridge: Exposes the
miphantAPI to the renderer viacontextBridge - Main Process: Manages windows, menus, dialogs and the server lifecycle
- HTTPS Server: Node.js server with auto-generated self-signed certificate, routes requests to PHP via FastCGI
- PHP Runtime: Static PHP binary communicating over FastCGI protocol
- Linux:
php-fpm— persistent process manager with dynamic worker pool - Windows:
php-cgi.exe— CGI binary in FastCGI mode
- Linux:
The server/ directory contains modular Node.js server components:
| Module | Description |
|---|---|
http-server.js |
HTTPS server with TLS, static file serving, FastCGI routing |
php-manager.js |
PHP process lifecycle: start, stop, FPM pool config (Linux), CGI binding (Windows) |
fastcgi.js |
FastCGI protocol implementation for PHP communication |
certificates.js |
Auto-generation of self-signed TLS certificates |
logger.js |
Centralized logger with verbose mode controlled by config.dev.tools |
utils.js |
Utility functions: free port finder, MIME types, port wait |
- Binary:
php-fpm - Mode: Persistent process manager (FPM)
- Config: Dynamically generated
php-fpm.confwith pool settings - Workers: Dynamic pool based on CPU cores (2 to 16 children)
- Advantages: Persistent processes, better performance for multiple requests
- Binary:
php-cgi.exe - Mode: CGI binary bound to a port in FastCGI mode
- Config: No configuration file needed
- Arguments:
-b 127.0.0.1:<port> - Advantages: No external dependencies, works out of the box
Both platforms use the same FastCGI protocol for communication. The Node.js server sends CGI parameters (request method, headers, query string, script filename, etc.) to the PHP process, which returns HTTP headers and body. The HTTPS server parses the PHP response and forwards it to the Electron renderer.
PHP library included in app/libs/ for building desktop applications. No Composer required — files are loaded directly via require_once.
| Class | Description |
|---|---|
config |
Read values from app/config.json with nested key access |
functions |
PHP helpers that generate JavaScript calls (alerts, confirm, newWindow, tray, etc.) |
about |
About page generator with license display |
file |
File operations: exists, open, save, create, remove |
path |
Cross-platform path builder using OS separator |
router |
URL router for multi-page PHP applications |
| Class | Description |
|---|---|
translate |
i18n translation with automatic fallback chain (pt-br → pt.json → en.json) |
| Class | Description |
|---|---|
env |
Access MiPhant environment variables (MIPHANT_LANG, MIPHANT_USERNAME, etc.) |
server |
Server helpers: domain, URI, document root |
platform |
OS detection: osLinux(), osWindows() |
require_once __DIR__ . '/libs/app/config.php';
require_once __DIR__ . '/libs/app/functions.php';
require_once __DIR__ . '/libs/langs/translate.php';
require_once __DIR__ . '/libs/system/server.php';
require_once __DIR__ . '/libs/system/env.php';
use MiPhantLibs\app\config;
use MiPhantLibs\app\functions;
use MiPhantLibs\langs\translate;
$cfg = new config();
$func = new functions();
$translate = new translate();
// Read config
$width = $cfg->get('app', 'width');
// Show translated alert
$func->alert('Info', $translate->get('Server has been started successfully.'), 'info');
// Open new window
$func->noTag()->newWindow('page.php', 800, 600);The miphant object is available in the renderer process (via preload.js) and provides the following methods:
| Method | Description |
|---|---|
miphant.version(type) |
Get version: 'miphant', 'electron', 'node', 'chromium' |
miphant.close() |
Close the application |
| Method | Description |
|---|---|
miphant.alert(title, msg, type, button) |
Display an alert dialog |
miphant.confirm(title, msg, type, ...buttons) |
Display a confirmation dialog |
miphant.openFile(multi) |
Open file dialog. multi: true for multiple selection |
miphant.saveFile() |
Save file dialog |
miphant.selectDirectory() |
Select directory dialog |
| Method | Description |
|---|---|
miphant.newWindow(url, width, height, resizable, frame, hide, menu) |
Open a new application window |
miphant.openURL(url) |
Open URL in the external browser |
| Method | Description |
|---|---|
miphant.notification(title, text) |
Display a system notification |
miphant.tray(title, tooltip, icon, menu) |
Create a system tray icon with context menu |
miphant.devTools() |
Open Chromium DevTools |
miphant.fileExists(filename) |
Check if a file exists |
miphant.exportPDF(filename, options) |
Export the current page to PDF |
| Method | Description |
|---|---|
miphant.translate(text, ...values) |
Translate a text string using the language files |
Accessed via $_ENV in PHP:
| Variable | Description |
|---|---|
$_ENV['MIPHANT_LANG'] |
System language (e.g. 'pt-br', 'en') |
$_ENV['MIPHANT_USERNAME'] |
Current system username |
$_ENV['MIPHANT_HOMEDIR'] |
User home directory |
$_ENV['MIPHANT_PLATFORM'] |
Platform: 'linux' or 'win32' |
$_ENV['MIPHANT_ARGV'] |
Command-line arguments passed to the app |
The application is configured via app/config.json:
{
"app": {
"id": "miphant",
"name": "MiPhant",
"version": "5.0.0",
"width": 800,
"height": 600,
"resizable": true,
"frame": true,
"hide": false,
"icon": "miphant.png",
"disableAccelerationHardware": true,
"author": {
"name": "Murilo Gomes",
"email": "profmugomes@gmail.com",
"url": "https://www.profmugomes.com.br"
},
"homepage": "https://github.com/profmugomes/miphant/",
"license": "MIT",
"copyright": "Copyright (C) 2025-2026 Murilo Gomes <profmugomes.com.br>"
},
"server": {
"perm": false,
"router": false
},
"dev": {
"menu": true,
"tools": false
}
}app
id: Application identifiername: Application nameversion: Application versionwidth/height: Default window dimensionsresizable: Allow window resizingframe: Show window frame (title bar)hide: Start with window hiddenicon: Icon filename (placed inapp/icon/)disableAccelerationHardware: Disable GPU hardware accelerationauthor: Author info (name, email, url)homepage: Project homepage URLlicense: License typecopyright: Copyright notice
server
perm: Auto-apply execute permission to PHP binary (Linux)router: Enable PHP built-in router
dev
menu: Show the Dev menu (Build, Refresh, Tools)tools: Auto-open DevTools on window creation
MiPhant includes a dark theme design system in app/style.css with:
- CSS custom properties for colors, spacing, and typography
- Card, button, table, badge, and form components
- Responsive grid layout
- Consistent visual language across all demo pages
To use in your pages:
<link rel="stylesheet" href="style.css">| Class | Description |
|---|---|
.card |
Content container with dark background |
.btn |
Button base class |
.btn-primary |
Primary action button |
.btn-outline |
Outlined button |
.badge |
Small label |
.badge-info |
Info-colored badge |
.text-muted |
Muted text color |
.collapsible |
Collapsible button (for license sections) |
Menus are defined as JSON files in app/menus/. The main menu is menu.json. Each PHP page can have a custom menu by creating a JSON file with the same name (e.g., message.json for message.php).
{
"Menu Label": {
"Item Label": {
"key": "Ctrl+O",
"page": "/page.php",
"newwindow": true,
"width": 600,
"height": 400
},
"separator1": {},
"External Link": {
"url": "https://example.com"
},
"Run Script": {
"script": "console.log('hello')"
}
}
}key: Keyboard shortcut (Electron accelerator format)page: PHP page path to navigate tonewwindow: Open in a new window (default:false, navigates in current window)width/height: Window dimensions for new windowsresizable/frame/hide: Window options for new windowsurl: Open an external URL in the system browserscript: Execute JavaScript in the current window
MiPhant supports multiple languages with automatic fallback chain. Create JSON files in app/langs/ with the language code as filename.
When a language is detected (e.g. pt-br), the system tries:
pt-br.json— exact matchpt.json— base languageen.json— English fallback
{
"Continue": "Continuar",
"Cancel": "Cancelar",
"Unable to find file %s": "Não foi possível encontrar o arquivo %s",
"Server has been started successfully.": "O servidor foi iniciado com sucesso."
}MiPhant includes 17+ demo pages showcasing all features:
| Page | Description |
|---|---|
index.php |
Home page with navigation to all demos |
about.php |
System information and license |
env.php |
Environment variables display |
args.php |
Command-line arguments |
message.php |
Alert and confirm dialogs |
notification.php |
System notifications |
openfile.php |
Open file dialog |
openfiles.php |
Multiple file selection |
savefile.php |
Save file dialog |
selectdirectory.php |
Directory selection |
cookies.php |
Cookie management |
session.php |
Session management |
sqlite.php |
SQLite database operations |
formget.php |
GET form handling |
formpost.php |
POST form handling |
translate.php |
i18n translation demo |
timezone.php |
Timezone configuration |
pdf.php |
PDF export |
extramenu.php |
Custom menus per window |
phpinfo.php |
PHP configuration info |
libs.php |
MiPhantLibs API documentation |
preload-doc.php |
Preload API documentation |
miphant/
├── main.js # Electron main process
├── preload.js # Preload bridge (miphant API)
├── mifunctions.js # IPC handlers (dialogs, tray, PDF, etc.)
├── milang.js # Language detection and translation
├── server/ # Node.js server modules
│ ├── http-server.js # HTTPS server with FastCGI routing
│ ├── php-manager.js # PHP process management (FPM/CGI)
│ ├── fastcgi.js # FastCGI protocol implementation
│ ├── certificates.js # Self-signed certificate generation
│ ├── logger.js # Centralized logger
│ └── utils.js # Utility functions
├── app/ # PHP application files
│ ├── config.json # Application configuration
│ ├── style.css # Dark theme design system
│ ├── index.php # Default start page
│ ├── langs/ # Translation files (pt.json, en.json)
│ ├── menus/ # Menu definitions (menu.json)
│ ├── libs/ # MiPhantLibs PHP library
│ │ ├── app/ # App classes (config, functions, file, path, about, router)
│ │ ├── langs/ # Translation class
│ │ ├── system/ # System classes (env, server, platform)
│ │ └── security/ # Security utilities
│ └── *.php # Demo pages
├── php/ # PHP binaries and configuration
│ ├── php.ini # PHP configuration file
│ ├── php-fpm # PHP-FPM binary (Linux)
│ └── php-cgi.exe # PHP-CGI binary (Windows)
├── staticphp/ # Static PHP build artifacts
│ ├── linux/ # Linux: php-fpm + build metadata
│ └── win32/ # Windows: php-cgi.exe + build metadata
└── electron-builder.yml # Electron Builder configuration
- Node.js 18+
- npm
npm installnpm start./config-dev.shnpm run dist-linuxnpm run dist-win./compile.sh- Architecture: x64
- Debian 12 or higher
- Ubuntu 22.04 or higher
- Windows 10 or higher
- Visual C++ Redistributable 14.42
The static PHP binary includes the following extensions:
bcmath, calendar, ctype, curl, dom, exif, fileinfo, filter, gd, iconv, mbstring, mbregex, mysqli, mysqlnd, opcache, openssl, pcntl, pdo, pdo_mysql, pdo_sqlite, phar, posix, readline, redis, session, simplexml, sockets, sodium, sqlite3, tokenizer, xml, xmlreader, xmlwriter, zip, zlib
- GitHub: https://github.com/sponsors/profmugomes/
- LivePix: https://livepix.gg/profmugomes
Copyright (c) 2025-2026 Murilo Gomes <profmugomes.com.br>
Licensed under the MIT license.
All contributions to the MiPhant are subject to this license.