Uncategorized

NativePHP Mobile Setup: The Ultimate Laravel 13 and Jump Guide

NativePHP - Laravel mobile setup
Create Ticket

For years, mobile app development required PHP developers to venture completely outside their comfort zones. You either had to master entirely separate ecosystems like Swift and Kotlin, or struggle with complex cross-platform wrappers like React Native and Flutter.

With NativePHP Mobile, that era is officially over.

This comprehensive guide walks you through the entire NativePHP Mobile setup lifecycle using Laravel 13 and the revolutionary Jump companion tool. We will cover everything from setting up your local environment and utilizing instant on-device testing to building and deploying a standalone production APK. By leveraging the modern features of Laravel 13, your web application can effortlessly transition into a high-performance native utility.

1. Environment Preparation for NativePHP Mobile Setup

Before diving into the codebase, we must prepare your development machine. NativePHP handles the heavy lifting, but it relies on key underlying software packages to build and compile mobile assets successfully.

Minimum System Specifications

  • Operating System: Windows 10/11 (via WSL2 recommended for best performance, though native Windows is supported), macOS (Intel or Apple Silicon), or Linux (Ubuntu 22.04 LTS or newer).
  • RAM: Minimum 8GB (16GB highly recommended, as Android Studio and Gradle builds are memory-intensive).
  • Storage: 15GB+ of free space for Android SDKs, command-line tools, and dependencies.

Technical Stack & Dependencies Table

DependencyMinimum Version RequiredPurpose in Stack
PHP8.3 (PHP 8.4 recommended)Required by Laravel 13 core framework
Composer2.7.0+PHP Package Manager
Node.js & npmNode 18.x / npm 9.xCompilation of frontend assets via Vite
Java Development Kit (JDK)OpenJDK 17Required by the Gradle build system
Android SDKAPI Level 26 (Android 8.0) up to API Level 36Target SDK execution platform

Step 1.1: Installing Java Development Kit (JDK 17)

The Android Gradle build automation tool requires Java 17 to compile the native wrapper components of your NativePHP application.

  • Windows (via Chocolatey):
Bash
choco install openjdk17
  • macOS (via Homebrew):
Bash
brew install openjdk@17
  • Linux (Ubuntu/Debian):
Bash
sudo apt update
sudo apt install openjdk-17-jdk -y

To confirm that everything is correct, verify your installation by running:

Bash
java -version

Ensure the output indicates a version matching 17.x.x.

Step 1.2: Installing and Configuring Android Studio

To compile a native Android application package, your system needs access to the Android Software Development Kit (SDK) and build engines.

  1. Download Android Studio from the official Android Developer Portal.
  2. Run the installer and choose the Standard Installation option.
  3. Open Android Studio. On the welcome screen, navigate to More Actions $\rightarrow$ SDK Manager.
  4. Under the SDK Platforms tab, ensure Android 14.0 (UpsideDownCake) or your desired target SDK (up to API Level 36) is selected.
  5. Switch to the SDK Tools tab and ensure the following are checked:
  6. Click Apply and wait for the downloads to complete. Note down the Android SDK Location path provided at the top of the window.

Step 1.3: Setting System Environment Variables

Your operating system terminal needs to know exactly where to find Java and the Android SDK command-line utilities.

Windows (System Environment Variables)

Add the following to your System Environment Variables:

  • Variable Name: JAVA_HOME -> Value: C:\Program Files\OpenLogic\openjdk-17... (or your actual JDK path)
  • Variable Name: ANDROID_HOME -> Value: C:\Users\YourUsername\AppData\Local\Android\Sdk

Modify your Path variable to append:

  • %ANDROID_HOME%\cmdline-tools\latest\bin
  • %ANDROID_HOME%\platform-tools

macOS and Linux (.zshrc or .bashrc)

Open your profile file and append these paths:

Bash
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin

Apply the changes by executing source ~/.zshrc or source ~/.bashrc.

2. Bootstrapping Laravel 13 for NativePHP Mobile Setup

With the foundational environment completely provisioned, let’s spin up a brand new Laravel 13 application framework.

Bash

laravel new native-mobile-app --git --no-interaction
cd native-mobile-app

Laravel 13 introduces native PHP 8 Attributes for core framework components, dropping support for older PHP runtimes and establishing PHP 8.3 as the strict minimum version requirement.

Verify your development server capabilities by running:

Bash

php artisan serve

Open [http://127.0.0.1:8000](http://127.0.0.1:8000) in your web browser to confirm your application baseline environment is functional. For more details on scaffolding layout options, check out our companion article on internal app layout patterns.

3. Configuring the NativePHP Mobile Setup Environment

Now we will install NativePHP Mobile inside our Laravel 13 core setup. This package pulls down the structural scaffolding required to cross-compile your PHP code directly into native architectures.

Step 3.1: Require the Mobile Package via Composer

Execute the following command within your root terminal directory:

Bash

composer require nativephp/mobile

Step 3.2: Run the NativePHP Installer

Initialize the framework configurations and download pre-compiled operational assets:

Bash

php artisan native:install

During this step, the installer will ask which platform wrappers you want to configure. Select Android (or choose both if you plan to target iOS later). The artisan command generates a dedicated configuration file located at config/nativephp.php.

Step 3.3: Understanding config/nativephp.php

Open your newly created configuration file. This file controls the runtime rules for your application on mobile devices. Let’s analyze the vital settings for Android:

PHP

return [
    'app_id' => env('NATIVEPHP_APP_ID', 'com.yourcompany.nativeapp'),
    'app_version' => env('NATIVEPHP_APP_VERSION', '1.0.0'),
    'app_version_code' => env('NATIVEPHP_APP_VERSION_CODE', 1),
    
    'android' => [
        'compile_sdk' => 36,
        'min_sdk' => 26, // Android 8.0 minimum support
        'target_sdk' => 36,
        'minify_enabled' => false,
        'shrink_resources' => false,
    ],

    'development' => [
        'http_port' => env('NATIVEPHP_HTTP_PORT', 3000),
        'ws_port' => env('NATIVEPHP_WS_PORT', 8081),
        'service_name' => env('NATIVEPHP_SERVICE_NAME', 'NativePHP Server'),
        'open_browser' => true,
    ],
];

4. Deep Dive: What is the Jump Companion?

Laravel Project + PHP Dev Machine

What is Jump?

Jump is an open-source companion mobile runtime application designed specifically by the NativePHP core team. Available directly on the Google Play Store and Apple App Store, it serves as an immediate testing vessel for your NativePHP Mobile setup operations.

Why Jump is Required for NativePHP Mobile Development

Traditional mobile development models require compiling your source code every time you make a change. A standard Android Gradle build loop can take anywhere from 45 seconds to several minutes, drastically slowing down web developers accustomed to instant page refreshes.

Jump bypasses compilation entirely. Instead of waiting for full APK packaging and installation processes, Jump allows you to run your local codebase inside a pre-built native container on a real phone instantly.

How Jump Communicates with Laravel Applications

When you start a Jump session on your development machine, an orchestration framework creates a two-way real-time data tunnel:

  1. The Web Layer: Jump utilizes your local device’s high-performance native WebView to render the frontend layout served from your workstation.
  2. The Native Bridge: Under standard production builds, commands like Camera::open() or Device::vibrate() run completely local to the physical processor container. In a Jump environment, NativePHP transparently intercepts these calls. Your local machine sends the request across a dedicated local TCP port link; the Jump app executes the operation directly on the phone and returns the result back to your workstation’s PHP execution pipeline.

The Role of Jump During Local Development and Testing

Jump acts as your on-device emulator sandbox. It enables hot-reloading asset changes via Vite’s Hot Module Replacement (HMR) capabilities. The moment you save a Blade file, a Livewire component, or a CSS rule on your computer, the change renders instantly on your physical phone without terminating your application session.

Difference Between Jump and a Production APK

Functional CriteriaThe Jump Application SandboxProduction APK / AAB Bundle
Compilation RequirementNone. Runs instantly.Requires full Gradle packaging steps.
PHP Runtime LocationExecuted on your local dev machine.Embedded directly inside the device binary.
Network RelianceRequires a shared local Wi-Fi connection.Operates completely standalone/offline.
Target DistributionExclusively for developers/internal teams.Distributed via Google Play Store.

5. Installing Jump on Android for NativePHP Mobile Setup

Let’s walk through deploying Jump to your hardware setup to complete our local environment synchronization.

Step 5.1: Downloading and Installing Jump

  1. Grab your Android test device and open the Google Play Store.
  2. Search for “Bifrost Jump” or navigate directly to the official download link at NativePHP Bifrost.
  3. Tap Install to add the application container to your mobile environment.
Jump App Play Store Page

Step 5.2: Enabling Required Android System Permissions

To test native integration workflows properly, open Settings ->Apps -> Jump on your Android device and grant the following permissions:

  • Camera: Required for QR code connection processing and media testing.
  • Local Network / Devices Discovery: Essential for discovering your developer workstation.
  • Notifications: For validating real-time push events.

Step 5.3: Enabling USB Debugging on Your Android Device

While Jump communicates primarily over Wi-Fi, keeping USB debugging enabled ensures stable data bridges and accessible logging readouts:

  1. On your Android device, go to Settings $\rightarrow$ About Phone.
  2. Tap Build Number seven consecutive times until a message reads "You are now a developer!".
  3. Return to the main Settings menu, locate Developer Options, and toggle USB Debugging to On.
  4. Connect your phone to your computer via a USB data cable. A prompt will appear on your phone asking to authorize access; select Always Allow from this Computer.

Step 5.4: Verifying Device Connectivity

Confirm that your development machine can detect the connected hardware by executing this command in your workstation terminal:

Bash

adb devices

The terminal should output a device ID followed by the word device. If it shows unauthorized, check your phone’s screen for the permission prompt.

6. Running and Testing the NativePHP Mobile Setup with Jump

Let’s tie your local codebase directly to your physical testing hardware.

Step 6.1: Start the Frontend Asset Bundler

Open a terminal window inside your project root and start the Vite dev server to manage hot-reloading frontend interactions:

Bash
npm run dev

Step 6.2: Launch the Jump Artisan Engine

Open a separate terminal window and execute the native jump daemon:

Bash

php artisan native:jump

NativePHP will analyze your active network interfaces. If your computer utilizes multiple network cards (such as a hardwired ethernet connection alongside a Wi-Fi connection or an active developer VPN), the terminal will ask you to select an IP address:

IP address your mobile device

Always select your Wi-Fi interface IP address to ensure your phone can route packets directly to your workstation. Once selected, a large QR code will render directly inside your terminal console window.

Laravel- NativePHP- QR code Scanner

Step 6.3: Connecting the Jump Client Container

  1. Launch the Jump App on your Android device.
  2. Tap the Scan QR Code action icon.
  3. Align your device camera with the QR code displayed in your terminal.
  4. Within moments, your phone will connect to your development machine and display your Laravel home screen.
Jump App - Scan QR Code

Step 6.4: Testing Hot Reload Capabilities

Open resources/views/welcome.blade.php inside your IDE and modify any text snippet within the file body. Save the changes. The Jump viewport on your physical phone will instantly update without a manual refresh.

7. Real-Device Feature Integration Testing

Let’s test native mobile components directly within your PHP logic using NativePHP facades to confirm our layout functions flawlessly.

Testing Haptics & Device Vibrations

To trigger physical haptic patterns from a Livewire controller or standard controller block, import the device facade:

PHP

use Native\Mobile\Facades\Device;

public function triggerHapticFeedback()
{
    // Trigger standard device vibration response
    Device::vibrate();
}

Testing the Device Camera

Capture media and pass references back directly into your backend logic:

PHP

use Native\Mobile\Facades\Camera;

public function captureUserAvatar()
{
    // Launches native hardware camera capture interface
    $imagePath = Camera::open();
    
    if ($imagePath) {
        // Process file stream internally
        auth()->user()->update(['avatar_path' => $imagePath]);
    }
}

Testing Biometric Authentication

You can secure administrative portals using on-device hardware fingerprint scanners:

PHP

use Native\Mobile\Facades\Biometrics;

public function verifySecurityClearance()
{
    $passed = Biometrics::authenticate('Verify your identity to proceed');

    if ($passed) {
        $this->dispatch('access-granted');
    }
}

8. Troubleshooting the NativePHP Mobile Setup Workspace

Error 1: Jump Cannot Connect to Laravel Server

  • Cause: The mobile device cannot find the route to your workstation’s IP address.
  • Solution:
    1. Verify both your mobile phone and development machine are connected to the exact same Wi-Fi SSID network.
    2. Ensure your computer’s firewall is not blocking incoming requests on ports 3000 through 3005.
    3. Run ufw allow 3000:3005/tcp (on Linux) or update your Windows Advanced Defender Firewall rules to allow these connections.

Error 2: Invalid QR Code Formats

  • Cause: The artisan command detected a VPN interface IP address instead of your local Wi-Fi adapter’s network address.
  • Solution: Close the active terminal session via Ctrl + C. Restart using php artisan native:jump --ip=192.168.1.XX, explicitly passing your local Wi-Fi IP address.

Error 3: PHP Binary Failure on Boot

  • Cause: The system environment paths are broken, or Android Studio tools are pointing to conflicting architecture binaries.
  • Solution: Explicitly set the environment pointer path inside your .env project structure:
Code Snippet

NATIVEPHP_ANDROID_SDK_LOCATION="C:\Users\YourUsername\AppData\Local\Android\Sdk"

9. Frequently Asked Questions (FAQ)

Q1: Can I use standard Composer packages inside a NativePHP mobile app?

Yes. Any pure PHP package or Laravel specific ecosystem extension (such as Spatie, Sushi, or Sanctum) works out of the box because a real PHP engine executes your code on the device.

Q2: Does NativePHP require an active internet connection to run?

No. The compiled PHP binary and your Laravel application reside completely on the device, allowing your app to function entirely offline.

Q3: Why does my app load slowly when using Jump during my NativePHP Mobile Setup?

When NATIVEPHP_APP_VERSION is set to DEBUG, NativePHP re-extracts your entire code archive on every boot to ensure you are seeing your latest changes. This behavior is disabled in production builds.

Q4: Does NativePHP Mobile support Laravel 13 Attributes?

Yes. NativePHP fully supports Laravel 13 and modern PHP 8 features, including core attributes for routing, models, and jobs.

Q5: How do I manage database storage on a mobile device?

NativePHP configures an isolated SQLite database configuration automatically upon deployment, storing persistent records securely within the application’s sandbox space.

Q6: Can I access the phone’s file storage directly?

Yes, using NativePHP’s filesystem bridge facades or standard Laravel Storage disk controls configured to point to internal app data paths.

Q7: Can I use tailwindcss and build tools via Vite?

Yes. Your asset builds are compiled using standard npm run build steps and embedded directly into the native mobile package wrapper.

Q8: What version of Android does NativePHP target?

By default, NativePHP configures a minimum SDK level of 26 (Android 8.0) and targets up to SDK level 36, covering the vast majority of active Android devices.

Q9: Do my app users need to install the Jump App?

No. Jump is exclusively a development environment tool. End users install your final standalone standalone APK or AAB bundle.

Q10: How do I handle user authentication?

You can use standard Laravel authentication scaffolding (like session-based state, Sanctum tokens, or Fortify configurations) completely locally.

Q11: Can I run scheduled tasks or background workers?

Yes, NativePHP Mobile exposes task scheduling bridges that map Laravel’s scheduler directly to native Android background service workers.

Q12: Why am I getting a “Java Home Not Found” error during NativePHP Mobile Setup?

This means the system path to your JDK installation is missing or misconfigured. Double-check your system’s JAVA_HOME environment variables.

Q13: Does Jump support hot-reloading for JavaScript frameworks?

Yes. Vite’s Hot Module Replacement (HMR) pipeline routes directly through Jump’s custom port bridges to update your UI instantly.

Q14: Is it possible to publish a NativePHP app to the Google Play Store?

Yes. The native:package command generates standardized release AAB/APK distribution bundles that comply with all standard Google Play store developer submission guidelines.

Q15: Can I build both iOS and Android apps from the same Laravel codebase?

Yes. A single codebase can build for both platforms. Note that compiling an iOS build requires a macOS machine with Xcode installed.

10. Conclusion

NativePHP Mobile completely redefines mobile development for PHP engineers. By combining the stability of Laravel 13 with the instant feedback loop of Jump, you can build, test, and ship native Android apps faster than ever before—all without touching a line of Kotlin or Java.

Leave a Reply

Your email address will not be published. Required fields are marked *