Overview
NativePHP Mobile provides a streamlined development workflow that lets you build, test, and iterate on your mobile apps quickly. The development cycle revolves around thenative:run command, which builds your app and deploys it to emulators or physical devices.
Development Cycle
The typical development workflow follows this pattern:Running Your App
Basic Usage
Thenative:run command builds and runs your app on iOS or Android:
Build Types
Choose between debug and release builds:- Debug: Fast builds with debugging enabled, ideal for development
- Release: Optimized builds for production testing
- Bundle: Android App Bundle format (AAB) for Play Store distribution
Device Selection
When running in debug mode, you’ll be prompted to select a target device:- Detect connected physical devices
- List available emulators
- Launch an emulator if none are running
Custom Start URL
Launch your app at a specific route:NATIVEPHP_START_URL in your .env file and loads that path when the app starts.
Hot Reload Development
Enable hot reload to automatically sync changes to your running app:- File changes are detected automatically
- Updates are pushed to the running app via WebSocket
- No need to rebuild and reinstall
Hot reload requires Watchman to be installed on your system. See the Hot Reload documentation for setup instructions.
Emulator vs Device Testing
Emulators/Simulators
Pros:- Fast to launch and test
- Easy to test multiple device sizes
- No physical hardware required
- Debugging tools readily available
- May not accurately represent device performance
- Some hardware features unavailable (camera, GPS, NFC)
- Graphics performance differs from real devices
Physical Devices
Pros:- True performance characteristics
- Access to all hardware features
- Real-world network conditions
- Accurate touch and gesture testing
- Requires device setup and connection
- May be slower for rapid iteration
- Limited to devices you own
Best Practices
Use emulators for rapid development
Use emulators for rapid development
Emulators are ideal for quick iterations during active development. They launch faster and don’t require device connectivity.
Test on real devices regularly
Test on real devices regularly
Run your app on physical devices at least once per major feature to catch performance issues and hardware-specific bugs.
Test on multiple device sizes
Test on multiple device sizes
Use emulators to quickly test different screen sizes and resolutions, especially for responsive layouts.
Test platform-specific features on real hardware
Test platform-specific features on real hardware
Features like push notifications, NFC, biometrics, and camera work best when tested on physical devices.
Build Logs
Build logs are automatically saved to help diagnose issues:Platform-Specific Requirements
Android
Required:- Android SDK installed
- ADB (Android Debug Bridge) in PATH
- At least one emulator or connected device
iOS (macOS only)
Required:- Xcode installed
- iOS Simulator or physical device
- Development team configured in
nativephp.php
Troubleshooting
App ID Not Set
NATIVEPHP_APP_ID to your .env file:
No Devices Found
- Ensure ADB is running:
adb devices - Launch an emulator from Android Studio
- Connect a physical device via USB with debugging enabled
WSL Not Supported (Android)
Build Failed
Check the build log for detailed error information:Non-Interactive Environments
For CI/CD pipelines, disable TTY mode:Next Steps
Hot Reload
Set up hot reload for faster development
Packaging
Package your app for distribution
iOS Deployment
Deploy to the App Store
Android Deployment
Deploy to Google Play Store