DEV Community

Steven Rojas
Steven Rojas

Posted on

How I embedded PHP 8.4 runtime directly into Android & iOS apps

For years, mobile development meant one of two extremes: either go full native (Kotlin/Swift) or pick a heavy JS framework (React Native, Flutter, Cordova/Capacitor) where your mobile app acts as a dumb API client fetching data from a remote server.

As a PHP developer, I kept asking myself: Why can't we execute real PHP business logic locally on the phone processor?

That's why I built Phphone (https://phphone.xyz) — an open-source compiler and runtime that packages an embedded PHP 8.4 engine directly into native Android and iOS mobile binaries.

šŸ—ļø The Architecture: Display vs. Embedded Engine

In Phphone, the WebView is only the display layer.
Unlike typical web wrappers where heavy JS frameworks bog down client performance, Phphone delegates business logic to the phone's CPU via embedded PHP 8.4:

  • Android: Runs a lightweight PHP 8.4 engine in native C++ via JNI.
  • iOS: Executes PHP natively through Swift bridge integrations.
  • Database: Integrated local SQLite3 for instant, offline relational persistence without network latency.
use Phphone\Device;
// Native hardware access directly from PHP:
Device::notification("Offline Alert", "Task saved to local SQLite!");
Device::vibrate(50);
$coords = Device::gps();
Enter fullscreen mode Exit fullscreen mode

šŸ” Built-in IP Protection: In-Memory AES-256
One of the biggest concerns developers have about shipping PHP on client devices is intellectual property.

To solve this, release builds (phphone build apk --release) cryptographically shield source files with AES-256-CBC. During runtime, controllers and business logic are decrypted symmetrically directly in RAM inside the native chassis (Kotlin/Swift). The PHP source is never exposed in plaintext inside the APK/IPA bundle.

šŸš€ Try it out
Phphone is free and open-source under Apache-2.0. We just tagged v1.0.2 with full iOS App and Android App Store compliance.

Website & Docs: https://phphone.xyz
GitHub Repository: https://github.com/phphone/phphone

I’d love to hear your thoughts, architectural critique, and answer any questions from the community!

Top comments (0)