Before you begin
Make sure you have a Laravel application ready. NativePHP Mobile requires:- PHP 8.3 or higher
- Laravel 10.x, 11.x, or 12.x
- Composer installed
If you don’t have a Laravel app yet, create one with:
composer create-project laravel/laravel my-mobile-appInstallation steps
Install the package
Install NativePHP Mobile via Composer:This will add the package to your Laravel application and register the service provider automatically.
Run the install command
Run the installation command to set up your mobile platforms:
iOS development is only available on macOS due to Xcode requirements.
What this command does
Thenative:install command performs several important tasks:- Prompts for your app bundle ID - Creates a unique identifier like
com.yourname.myapp - Publishes configuration files - Adds
config/nativephp.phpto your project - Creates the nativephp directory - Sets up
nativephp/androidand/ornativephp/ioswith native project files - Downloads PHP binaries - Embeds PHP runtime for your target platforms
- Copies CLI wrapper - Installs the
nativebinary for convenient commands
Configure your app ID
During installation, you’ll be prompted to set your app bundle ID. This uniquely identifies your app on the App Store and Google Play.The installer generates a suggestion like This sets
com.username.appname, but you should customize it:NATIVEPHP_APP_ID in your .env file:.env
Bundle IDs use reverse domain notation and must be unique. Choose carefully as changing it later requires updating app store listings.
Publish configuration (optional)
The config file is published automatically, but you can republish it anytime:This creates
config/nativephp.php where you can customize:- App version and version code
- Deep link schemes
- Start URL
- Development server ports
- Permissions
- Device orientation support
- Platform-specific settings
Platform-specific setup
- iOS
- Android
iOS development requirements
iOS development requires macOS and Xcode:Install Xcode
Download and install Xcode from the Mac App Store (free).After installation, open Xcode at least once to complete setup and accept the license agreement.
Set up iOS Simulator
Open Xcode and go to Xcode > Settings > Platforms to download iOS Simulator runtimes for your target iOS versions.
Configure development team (optional)
For running on physical devices, you’ll need an Apple Developer account:
- Sign up at developer.apple.com
- Find your Team ID in Membership section
- Add to your
.env:
.env
The free Apple Developer tier allows testing on your own devices. Paid membership ($99/year) is required for App Store distribution.
Install command options
Thenative:install command supports several options:
Arguments
platform- Specifyandroid,ios, orboth(interactive prompt if omitted)
Options
--forceor-F- Overwrite existing native project files--with-icu- Include ICU support for Android (adds ~30MB, enables internationalization)--without-icu- Exclude ICU support (default, smaller app size)--skip-php- Skip downloading PHP binaries (for offline development)
Examples
Verify installation
Check that everything is installed correctly:Configuration file overview
Theconfig/nativephp.php file contains all mobile app settings:
Troubleshooting
WSL not supported for Android
WSL not supported for Android
NativePHP Mobile does not support Android development in WSL (Windows Subsystem for Linux).Solution: Run commands from Windows CMD or PowerShell instead of WSL.
iOS requires macOS
iOS requires macOS
iOS development requires macOS hardware due to Xcode and Apple’s licensing restrictions.Solution: Use a Mac or Mac mini for iOS development, or focus on Android only.
PHP binary download fails
PHP binary download fails
If PHP binary downloads fail due to network issues:Solution: Retry the install command. For persistent issues, check your internet connection and firewall settings.
Gradle build errors (Android)
Gradle build errors (Android)
Gradle may fail if JDK is not configured correctly.Solution: Ensure JDK 17+ is installed and set
JAVA_HOME environment variable:Next steps
Quickstart tutorial
Build your first mobile app in under 5 minutes
CLI commands
Learn about the available NativePHP commands
Configuration
Explore all configuration options
Native features
Start using device features in your app