Skip to content

Repository files navigation

pam-native: Build real Android and iOS applications with typed PHP. No JavaScript runtime, no WebView.

Build real Android and iOS applications with typed PHP.
A Rust reconciler, retained native renderer, signals, navigation, UI-thread motion and modular platform capabilities.
No JavaScript runtime or WebView.

Packagist Latest release PHP 8.5 CI License

Install · Quick example · Zé Chat · Platforms · Docs · Issues

Built with PAM Native: Zé Chat

Zé Chat is a production chat app that was rewritten from React Native to PHP with PAM Native. These clips were recorded on a 2019 Galaxy S10.

Zé Chat inbox and conversation with the keyboard, built with PAM Native
Inbox, conversation, keyboard
Swipe to reply and long-press reactions in Zé Chat
Swipe to reply, long-press to react
Fast scroll through 150+ messages and the light and dark themes in Zé Chat
150+ messages, light and dark

Click a clip for the MP4. The public showcase (marketplace, finance dashboard, chat composer, offline field workflow) is in this repository; see the showcase guide.

Install

Create a PAM Native project and run it:

pam init my-app --template native
cd my-app
pam doctor --fix
pam dev

pam init --template native already adds pushinbr/pam-native (^1.0) to the project's composer.json; add capabilities with pam composer require pushinbr/pam-native-<capability>. The PAM Native overview covers prerequisites, production setup and the complete workflow. PAM projects keep normal manifests and lockfiles; product features stay in the package that owns them.

With the official component library, pam init my-app --template native-ui gives the same flow with PAM Native UI. On a Mac, pam mobile ios:run needs only Xcode: the CLI downloads, verifies (SHA-256) and caches the prebuilt iOS PHP runtime and engine of your exact versions (iOS engine and runtime). pam dev gives each Android app its own device port and keeps the running app when the installed bundle is already current, so pending native prompts and callbacks survive the first sync.

Every build follows the mandatory build hygiene contract: final APK/AAB/IPA/app deliverables are preserved in dist, while regenerable Gradle, Cargo and Xcode intermediates are removed when the command exits. Device bundles keep the PHP SDK and its resources; the SDK's native host sources and documentation stay on the development machine.

Advanced: install only the SDK

Generated PAM projects already configure this dependency. Direct Composer installation is intended for custom hosts and framework contributors:

pam composer require pushinbr/pam-native:^1.0

Quick example

Write familiar PHP components, state, actions and Laravel-inspired named routes. PAM keeps your PHP application alive, reconciles its interface in Rust, and renders real UIKit and Android controls.

<?php

use App\Screens\HomeScreen;
use App\Screens\ProductScreen;
use Pam\Native\App;
use Pam\Native\Routing\Route;

App::run(
    Route::stack('main', initial: 'home', routes: function (): void {
        Route::screen('home', HomeScreen::class);
        Route::screen('product', ProductScreen::class);
    }),
);

Platform support

Platform Support Notes
Android API 26+ by default, API 24+ with android.minSdk: 24; compiled against API 36 Real Android Views; API 26 and API 36 contracts; see Android 7.x
iOS 15.0+ (default ios.minimumVersion) UIKit controls; UIKit simulator tests

It feels familiar because it is

Use explicit PHP trees when you want complete control:

return Screen::make(
    SafeAreaView::make(
        Column::make(
            Text::make('Your cart')->style(new Style(fontSize: 28)),
            Text::make("{$this->items} items"),
            Button::make('Checkout')->onPress($this->checkout(...)),
        )->style(new Style(padding: 24, gap: 16)),
    ),
);

Or use single-file components when template authoring is a better fit:

final class Counter extends Component
{
    #[State]
    public int $count = 0;

    #[\Pam\Native\Attributes\Action]
    public function increment(): void
    {
        $this->count++;
    }
}
?>

<template language="2">
    <Column class="card">
        <Text class="title">Count: {{ $count }}</Text>
        <Button label="Increment" @press="increment" />
    </Column>
</template>

<style scoped>
    .card { padding: 24px; gap: 16px; }
    .title { font-size: 28px; font-weight: 700; }
</style>

Both styles compile to the same typed retained tree. Scoped styles become native properties; they are not browser CSS.

Language 2 adds typed tag/event/slot contracts, native interaction states, compiled tokens and recipes, viewport/container queries, declarative flow and async branches, stable virtual-list identity, compositor keyframes, accessibility diagnostics, Composer-extensible tags and a full editor-neutral LSP. Attributes such as #[Prop] and #[Action] remain the canonical PHP API. Read the UI Language 2 guide.

Lists and scroll views take React Native's pull to refresh directly (:refreshing, on:refresh, tintColor, refreshColors) with the platform indicator on each side: see Pull to refresh.

Need precise imperative control without introducing a browser runtime? The Visual DOM adds indexed selectors, atomic tree mutations, events, native animation and asynchronous layout observation directly on the same retained PHP → Rust → Android/UIKit pipeline.

A small chat app that shows the whole v2 architecture (globals, routes, middleware, composables and screens that use only setup()) is in docs/complete-app.md; the full reference is Architecture v2.

Native where it matters

  • Real Android Views and UIKit controls
  • Native stack, tabs, drawers, sheets, headers, gestures, and transitions
  • Recycled lists and grids for large datasets
  • Keyboard-safe inputs, safe areas, accessibility, and reduced motion
  • Camera, media library, audio, contacts, location, sensors, notifications, push, sharing, files, SQLite, and secure storage
  • Background execution and offline-first state
  • Native animation and gesture execution without per-frame PHP traffic
  • Hot reload, profiling, time travel, diagnostics, and repeatable benchmarks
  • A plugin SDK for application-specific native modules and views

PHP describes the experience. Rust performs reconciliation and layout. Kotlin and Swift apply bounded native mutations once per display frame.

Built for real products

PAM Native includes the parts that demos usually skip:

  • process and navigation restoration;
  • bounded payloads, queues, caches, and retained state;
  • typed integer-backed protocol enums;
  • exact-host WebView allowlists and canonical file access;
  • offline media caching and retry-safe operations;
  • API 26 and API 36 Android contracts;
  • UIKit simulator tests;
  • deterministic protocol fuzzing;
  • performance budgets and baseline profiles.

The public showcase includes a marketplace, finance dashboard, chat composer, offline field workflow, component lab, hot reload, and a recycled list with 10,000 rows.

Marketplace built with PAM Native Finance dashboard built with PAM Native Chat built with PAM Native Offline field app built with PAM Native

Explore the showcase source or follow the showcase guide to build it locally.

Optional Drawer and Toast (1.46)

Install pushinbr/pam-native-drawer for Drawer and pushinbr/pam-native-toast for Toast, and move the imports to Pam\Native\Drawer and Pam\Native\Toast. The old names use MovedToPlugin: with the package installed they are aliases; without it they print the Composer command. The core keeps the reserved IDs and the generic module/view hooks; it does not include the Drawer renderer or the Toast appearance and variants. The real-world app depends only on the Toast plugin.

Community

Bug reports, focused feature proposals, documentation fixes, components and plugins are welcome. Start with the contribution guide or open a discussion describing the application you want to build.

PAM Native is open source under Apache-2.0. You may build and sell proprietary or open applications with it without a revenue limit or runtime royalty. See LICENSING.md for the plain-language grant and the full LICENSE for controlling terms.

Docs

Part of the PAM ecosystem

PAM

PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.

PAM PAM Desktop Ecosystem
the runtime and CLI native desktop apps in PHP every official package and plugin

Docs: push-in.github.io/pam-docs · Issues

Apache License 2.0 · licensing guide · Made in Brazil by Pushin

Releases

Packages

Contributors

Languages