From nativephp-plugin-dev
This skill provides understanding of NativePHP Mobile internals. Use when the user asks about "how NativePHP works", "god method", "nativephp_call", "bridge functions", "bridge registration", "EDGE system", "element definition", "native events", "event dispatching", "WebView communication", or how PHP communicates with native iOS/Android code.
npx claudepluginhub NativePHP/ClaudePlugins --plugin nativephp-plugin-devThis skill uses the workspace's default tool permissions.
NativePHP Mobile enables Laravel developers to build native iOS and Android applications. This skill explains the core architecture.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
NativePHP Mobile enables Laravel developers to build native iOS and Android applications. This skill explains the core architecture.
nativephp_callThe foundation of NativePHP's native communication is the "god method" - nativephp_call. This single function handles ALL PHP-to-native communication.
// PHP side - calling native functionality
$result = nativephp_call('Dialog.Alert', [
'title' => 'Hello',
'message' => 'Welcome to NativePHP!'
]);
The call flows through:
nativephp_call('Method.Name', $params)Native bridge functions must be registered before they can be called. Registration maps method names to implementation classes.
Android (Kotlin):
fun registerBridgeFunctions(activity: FragmentActivity, context: Context) {
val registry = BridgeFunctionRegistry.shared
// Core NativePHP functions
registry.register("Dialog.Alert", DialogFunctions.Alert(activity))
registry.register("QrCode.Scan", QrCodeFunctions.Scan(activity))
registry.register("Network.Status", NetworkFunctions.Status(context))
// Plugin functions get registered here too
registry.register("MyPlugin.Execute", MyPluginFunctions.Execute(activity))
}
iOS (Swift):
func registerBridgeFunctions() {
let registry = BridgeFunctionRegistry.shared
registry.register("Dialog.Alert", DialogFunctions.Alert())
registry.register("QrCode.Scan", QrCodeFunctions.Scan())
registry.register("Network.Status", NetworkFunctions.Status())
// Plugin functions
registry.register("MyPlugin.Execute", MyPluginFunctions.Execute())
}
Bridge function names follow Namespace.Action pattern:
Dialog.Alert - Show an alert dialogCamera.Capture - Capture a photoHaptics.Vibrate - Trigger haptic feedbackMyPlugin.DoSomething - Plugin-specific actionEDGE is NativePHP's system for rendering native UI elements from PHP/Blade templates. Instead of rendering HTML, EDGE creates native iOS/Android UI.
// In a Blade template
<x-native::bottom-nav>
<x-native::bottom-nav-item
icon="home"
label="Home"
route="home"
/>
<x-native::bottom-nav-item
icon="settings"
label="Settings"
route="settings"
/>
</x-native::bottom-nav>
This generates a JSON structure that native code interprets to render a real native bottom navigation bar.
| Aspect | EDGE (Native) | WebView |
|---|---|---|
| Rendering | Native UIKit/Jetpack | HTML/CSS |
| Performance | Native speed | Web performance |
| Look & Feel | Platform native | Web-like |
| Use Case | Navigation, tabs, dialogs | App content |
When native code needs to notify PHP (e.g., photo captured, scan completed), it dispatches events.
import android.os.Handler
import android.os.Looper
import org.json.JSONObject
// MUST dispatch on main thread for JavaScript execution
Handler(Looper.getMainLooper()).post {
val payload = JSONObject().apply {
put("path", filePath)
put("mimeType", "image/jpeg")
}
NativeActionCoordinator.dispatchEvent(
activity,
"Native\\Mobile\\Events\\Camera\\PhotoCaptured",
payload.toString()
)
}
// Already on main thread typically
let payload: [String: Any] = [
"path": filePath,
"mimeType": "image/jpeg"
]
LaravelBridge.shared.send?(
"Native\\Mobile\\Events\\Camera\\PhotoCaptured",
payload
)
// Event class - simple POJO, no broadcasting
class PhotoCaptured
{
use Dispatchable, SerializesModels;
public function __construct(
public string $path,
public string $mimeType = 'image/jpeg'
) {}
}
// Livewire component listening for the event
class PhotoUploader extends Component
{
#[On('native:Native\Mobile\Events\Camera\PhotoCaptured')]
public function handlePhotoCaptured($path, $mimeType = null)
{
// Process the captured photo
$this->photoPath = $path;
}
}
ShouldBroadcast, no channels#[On('native:...')] - The native: prefix is requiredNativePHP apps run inside a WebView that loads PHP-rendered HTML:
┌─────────────────────────────────────┐
│ Native App Shell │
│ ┌───────────────────────────────┐ │
│ │ EDGE Native Elements │ │
│ │ (Bottom Nav, Status Bar) │ │
│ ├───────────────────────────────┤ │
│ │ │ │
│ │ WebView │ │
│ │ (PHP/Laravel Content) │ │
│ │ │ │
│ │ ┌─────────────────────┐ │ │
│ │ │ JavaScript Bridge │ │ │
│ │ │ (nativephp_call) │ │ │
│ │ └─────────────────────┘ │ │
│ │ │ │
│ └───────────────────────────────┘ │
│ │
│ ┌───────────────────────────────┐ │
│ │ Bridge Function Registry │ │
│ │ (Native Kotlin/Swift) │ │
│ └───────────────────────────────┘ │
└─────────────────────────────────────┘
During NativePHP installation, PHP binaries are downloaded that contain:
nativephp_callThese binaries are platform-specific and handle the low-level communication between PHP and native code.
| Concept | Purpose |
|---|---|
nativephp_call | PHP function to invoke native code |
| Bridge Functions | Native classes that handle nativephp_call requests |
| Bridge Registry | Maps method names to bridge function classes |
| EDGE | Native UI rendering from Blade components |
| Event Dispatching | Native-to-PHP communication via JavaScript injection |
| WebView | Container for PHP-rendered content |
$status = nativephp_call('Network.Status', []);
// Returns: ['connected' => true, 'type' => 'wifi']
$result = nativephp_call('Camera.Capture', ['quality' => 80]);
// Returns: ['id' => 'uuid-here']
// Later: native:Native\Mobile\Events\Camera\PhotoCaptured event fires
nativephp_call('Haptics.Vibrate', ['pattern' => 'success']);
// Returns: ['success' => true]
// No follow-up event