Overview
This quickstart guide will walk you through creating a simple mobile app that demonstrates NativePHP’s core capabilities. You’ll build an app that:- Displays a welcome screen
- Captures photos using the device camera
- Shows device information
- Provides haptic feedback
This guide assumes you’ve already installed NativePHP Mobile. If not, complete the installation first.
Build your first app
Create or prepare your Laravel app
Start with a fresh Laravel application or use an existing one:When prompted, enter your app bundle ID (e.g.,
com.yourname.myfirstapp).Create a mobile-friendly view
Create or update
resources/views/welcome.blade.php:resources/views/welcome.blade.php
Configure camera permissions
Add camera permissions to your
config/nativephp.php:config/nativephp.php
After changing permissions, re-run
php artisan native:install --force to update native project files.Run your app
Build and launch your mobile app:The app will build and launch in the iOS Simulator. If you have multiple simulators, you’ll be prompted to choose one.
- iOS
- Android
The first build may take a few minutes as Gradle downloads dependencies. Subsequent builds will be much faster.
Test the app
Once the app launches:
- Check device info - You’ll see device details displayed on screen
- Take a photo - Tap the “Take a Photo” button
- Grant camera permission - Allow camera access when prompted
- Capture an image - Take a photo or choose from gallery
- Feel the haptic - Your device will vibrate when the photo is captured
storage/app/photos/ in your Laravel application.Understanding the code
Let’s break down what’s happening in this quickstart app:Native facades
NativePHP provides simple facades to access device features:Platform detection
Blade directives help you write platform-specific code:API communication
Your mobile app communicates with your Laravel backend via standard HTTP requests:Development with hot reload
For the best development experience, use the--watch flag:
- PHP changes - Routes, controllers, and views automatically refresh
- Asset changes - CSS and JavaScript updates appear instantly
- No rebuilding - Changes appear without recompiling the app
Hot reload requires your development machine and mobile device/emulator to be on the same network.
Exploring more features
Now that you have a working app, try adding more features:Geolocation
Get the user’s current position and track movement
Secure storage
Store sensitive data securely on the device
Dialogs
Show native alerts, toasts, and share sheets
QR Scanner
Scan QR codes and barcodes
Quick example: Add geolocation
Add this to your routes:config/nativephp.php:
php artisan native:install --force and your app can now access GPS.
Building for production
When you’re ready to publish your app:- iOS
- Android
Troubleshooting
Camera not working
Camera not working
Make sure you:
- Added camera permission to
config/nativephp.php - Ran
php artisan native:install --forceafter adding permissions - Granted permission when the app prompted you
App won't launch
App won't launch
Common issues:
- iOS: Make sure iOS Simulator is installed in Xcode
- Android: Ensure an emulator is running or device is connected
- Check for errors with:
php artisan native:tail iosorphp artisan native:tail android
Hot reload not working
Hot reload not working
Ensure:
- Your device/emulator and computer are on the same network
- No firewall is blocking ports 3000 and 8081
- The development server started successfully
Build errors
Build errors
Try:
Next steps
Congratulations! You’ve built your first NativePHP Mobile app. Here’s what to explore next:Native features
Explore all available device features and APIs
CLI reference
Learn about all available commands and options
Configuration
Customize your app’s behavior and appearance
Deployment
Prepare your app for the App Store and Play Store
Join the NativePHP community on Discord to share your creations and get help from other developers!