Installation
NativePHP for Desktop and Mobile have reached v1!
On this page
#Get a license
Before you begin, you will need to purchase a license.
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.
Your license fee goes straight back into the NativePHP project and community, enabling us to:
- Develop premium features for everyone.
- Provide first-class support.
- Sponsor our dependencies.
- Donate to our contributors.
- Support community events.
- Ensure that the whole NativePHP project remains viable for a long time to come.
Thank you for supporting the project in this way! 🙏
#Install the Composer package
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.yourcompany.yourappNATIVEPHP_APP_VERSION="DEBUG"NATIVEPHP_APP_VERSION_CODE="1"
#Run the NativePHP installer
php artisan native:install
The NativePHP installer takes care of setting up and configuring your Laravel application to work with iOS and Android.
You may be prompted about whether you would like to install the ICU-enabled PHP binaries. You should install these if
your application relies on the intl
PHP extension.
If you don't need intl
or are not sure, choose the default, non-ICU builds.
#The nativephp
Directory
After running: php artisan native:install
you’ll see a new nativephp
directory at the root of your Laravel project
as well as a config/nativephp.php
config file.
The nativephp
folder contains the native application project files needed to build your app for the desired platforms.
You should not need to manually open or edit any native project files under normal circumstances. NativePHP handles the heavy lifting for you.
You should treat this directory as ephemeral. When upgrading the NativePHP package, it will be necessary to run
php artisan native:install --force
, which completely rebuilds this directory, deleting all files within.
For this reason, we also recommend you add the nativephp
folder to your .gitignore
.
#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
Just follow the prompts! This will start compiling your application and boot it on whichever device you select.
#Running on a real device
On iOS
If you want to run your app on a real iOS device, you need to make sure it is in Developer Mode and that it's been added to your Apple Developer account as a registered device.
On 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! 🎉