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
┌──────────────────────────────────────────────────────────┐
│ 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, PHP protocol routing |
php-manager.js |
PHP process lifecycle: start, stop, FPM pool config (Linux), CGI binding (Windows) |
php-protocol.js |
PHP protocol implementation for TCP communication with PHP-FPM/CGI |
config.js |
Centralized configuration: HOST, ports, timeouts, limits |
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 TCP 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() |
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": "6.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": "SEE LICENSE IN LICENSE.md",
"copyright": "Copyright (C) 2025-2026 Murilo Gomes <profmugomes.com.br>"
},
"server": {
"perm": true,
"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."
}- 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>. All rights reserved.
This project is licensed under the PolyForm Perimeter License 1.0.1.
You may:
- ✔ Use the software for any purpose (personal, educational, commercial).
- ✔ Inspect and study the source code.
- ✔ Modify the software and create derivative works.
- ✔ Distribute copies of the software (with or without modifications).
You may not:
- ✖ Provide a product that competes with the software.
A product competes with MiPhant if it is offered as a substitute for its functionality or value, regardless of:
- How it is designed or deployed.
- Whether it is provided via an interface (service, library, or plugin).
- Whether it is ported to another platform or programming language.
- Whether it is provided for free.
- Using MiPhant to build desktop applications for yourself.
- Using MiPhant in educational or research environments.
- Modifying MiPhant to suit your needs.
- Distributing MiPhant to third parties (without competitive intent).
- Creating a product that functions as an alternative to MiPhant.
- Offering a service that replaces MiPhant's functionality.
- Selling a modified version of MiPhant as a competing product.
See the full license terms in LICENSE.md.
This summary is provided for convenience only.