MyPHP Documentation
MyPHP builds desktop and mobile apps in pure PHP 8.3+. Each window shows one of two kinds of interface, and one app can have windows of both:
- A web page, in the native webview of the operating system (WKWebView on macOS/iOS, WebKitGTK on Linux) instead of a bundled browser. The frontend is HTML, CSS and JavaScript built with any tools (Vue, React, Svelte, Vite), and calls your PHP services through a typed TypeScript client that MyPHP generates from your classes.
- Native GPU UI, which MyPHP draws directly on the GPU, written in PHP alone with immediate mode UI: there is no HTML, no JavaScript and no webview to start, so windows open instantly and consume minimal RAM (~44MB).
Windows of both kinds share window options and lifecycle events, menus, system dialogs, push notifications and desktop/mobile APIs. The app is a single binary of a few megabytes.
A window with a web page and typed IPC
A PHP backend service exposed to the web frontend:
use MyPHP\{App, Window, WindowOptions};
final class GreeterService {
public function greet(string $name): string {
return "Hello, " . $name . "!";
}
}
App::whenReady(function () {
App::bind(new GreeterService());
new Window(new WindowOptions(
title: "Hello Web",
url: "myphp://localhost/"
));
});
App::run();
In your frontend TypeScript:
import { myphp } from "./myphp"; // Auto-generated typed client
document.body.textContent = await myphp.greeter.greet("World");
A window with native GPU immediate mode UI
The view is a pure PHP function of your application state, rebuilt on each frame and drawn by GPU shaders:
use MyPHP\{App, Window, WindowOptions};
use MyPHP\UI\{Content, Context};
$count = 0;
App::whenReady(function () use (&$count) {
new Window(new WindowOptions(
title: "Counter",
width: 360,
height: 240,
content: Content::view(function (Context $c) use (&$count) {
$c->column(pad: 24, gap: 12, align: 1);
$c->text("Tapped: $count", size: 28);
if ($c->clicked($c->button("Increment"))) {
$count++;
}
$c->end();
})
));
});
App::run();
Supported Platforms
- macOS (12.0+ on Apple Silicon & Intel): Metal GPU rendering, CoreText typography, system appearance and dark mode.
- iOS (16.0+): Metal 120Hz ProMotion pacing, touch-slop and exponential momentum fling, UIKeyInput soft keyboard, notch and Dynamic Island safe area insets.
- Android (12.0+ / API 31+): EGL + GLES 3.2 shaders, Android 12 TextRunShaper, BaseInputConnection Chinese IME, zero-Gradle 2-second packaging.
- Linux (Debian, Arch, Ubuntu): GTK 3, OpenGL and Pango text engine.