Installation
NativePHP for desktop and mobile have reached v1!
On this page
#Requirements
- PHP 8.3+
- Laravel 10 or higher
- An Apple Silicon Mac running macOS 12+ with Xcode 16+
- An active Apple Developer account
- A NativePHP for mobile license
- Optional iOS device
For iOS
- An Apple Mac (ideally Silicon) running macOS 12+ with Xcode 16+
- An active Apple Developer account
- You can download Xcode from the Mac App Store
For Android
- Android Studio Giraffe (or later)
- The following environment variables set.
- You should be able to successfully run
java -v
andadb devices
from the terminal. - Windows only: You must have 7zip installed.
For macOS
export JAVA_HOME=$(/usr/libexec/java_home -v 17) // This isn't required if JAVA_HOME is already set in the Windows Env Variablesexport ANDROID_SDK_ROOT=$HOME/Library/Android/sdkexport PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
For Windows
set ANDROID_SDK_ROOT=C:\Users\yourname\AppData\Local\Android\Sdkset PATH=%PATH%;%JAVA_HOME%\bin;%ANDROID_SDK_ROOT%\platform-tools # This isn't required if JAVA_HOME is already set in the Windows Env Variablesset JAVA_HOME=C:\Program Files\Microsoft\jdk-17.0.8.7-hotspot
Note You cannot build iOS apps on Windows or Linux
You don't need a physical iOS/Android device to compile your application and test it for your app, as NativePHP for mobile supports the iOS Simulator and Android emulators. However, we highly recommend that you test your application on a real device before submitting to the App/Google Play Store.
#Laravel
NativePHP for mobile is built to work with Laravel. You can install it into an existing Laravel application, or start a new one. The most painless way to get PHP and Node up and running on your system is with Laravel Herd. It's fast and free!
#Install NativePHP for mobile
To make NativePHP for mobile a reality has taken a lot of work and will continue to require even more. For this reason, it's not open source, and you are not free to distribute or modify its source code.
Before you begin, you will need to purchase a license. Licenses can be obtained here.
Once you have your license, you will need to add the following to your composer.json
:
"repositories": [ { "type": "composer", "url": "https://nativephp.composer.sh" }],
Then run:
composer require nativephp/mobile
If this is the first time you're installing the package, you will be prompted to authenticate. Your username is the email address you used when purchasing your license. Your password is your license key.
This package contains all the libraries, classes, commands, and interfaces that your application will need to work with iOS and Android.
Before running the install
command it is important to set the following variables in your .env
:
NATIVEPHP_APP_ID=com.nativephp.yourappNATIVEPHP_APP_VERSION="DEBUG"NATIVEPHP_APP_VERSION_CODE="1"
#Run the NativePHP installer
php artisan native:install
The NativePHP installer works similarly to NativePHP for desktop, taking care of setting up and configuring your Laravel application to work with iOS and/or Android.
#Start your app
Heads up! Before starting your app in a native context, try running it in the browser. You may bump into exceptions which need addressing before you can run your app natively, and may be trickier to spot when doing so.
Once you're ready:
php artisan native:run
This will start compiling your application and boot it on whichever device you select.
#Running on a real device
For iOS
If you want to run your app on a real mobile device, you need to make sure the device is in Developer Mode and that it's been added to your Apple Developer account as a registered device.
For Android
On Android you need to enable developer options and have USB debugging (ADB) enabled.
And that's it! You should now see your Laravel application running as a native app! 🎉