CI/CD Integration
NativePHP for Desktop and Mobile have reached v1!
On this page
#Overview
NativePHP for Mobile provides robust CLI commands designed for automated CI/CD environments. With proper configuration, you can build, package, and deploy mobile apps without manual intervention.
#Key Commands for CI/CD
#Installation Command
Install NativePHP dependencies in automated environments:
# Install Android platform, overwriting existing filesphp artisan native:install android --force --no-tty# Install with ICU support for Filament/intl featuresphp artisan native:install android --force --with-icu# Install both platformsphp artisan native:install both --force
#Build Commands
Build your app for different environments:
# Build debug version (development)php artisan native:run android --build=debug --no-tty# Build release version (production)php artisan native:run android --build=release --no-tty# Build app bundle for Play Storephp artisan native:run android --build=bundle --no-tty
#Packaging Command
Package signed releases for distribution:
# Package signed APK using environment variablesphp artisan native:package android --build-type=release --output=/artifacts --no-tty# Package signed App Bundle for Play Storephp artisan native:package android --build-type=bundle --output=/artifacts --no-tty
#Environment Variables
Store sensitive signing information in environment variables:
# Android SigningANDROID_KEYSTORE_FILE="/path/to/keystore.jks"ANDROID_KEYSTORE_PASSWORD="your-keystore-password"ANDROID_KEY_ALIAS="your-key-alias"ANDROID_KEY_PASSWORD="your-key-password"
#Command Line Options
#--no-tty
Flag
Essential for CI/CD environments where TTY is not available:
- Disables interactive prompts
- Provides non-interactive output
- Shows build progress without real-time updates
- Required for most automated environments
#--force
Flag
Overwrites existing files and directories:
- Useful for clean builds in CI
- Ensures fresh installation of NativePHP scaffolding
- Prevents build failures from existing files
- Do this whenever you are updating the
nativephp/mobile
package.
#Build Types
--build=debug
: Development builds with debugging enabled--build=release
: Production builds optimized for distribution--build=bundle
: App bundles for Play Store distribution
#Signing Configuration
#Using Command Line Options
php artisan native:package android \ --build-type=release \ --keystore=/path/to/keystore.jks \ --keystore-password=your-password \ --key-alias=your-alias \ --key-password=your-key-password \ --output=./artifacts \ --no-tty
#Using Environment Variables (Recommended)
# Set environment variables in CIexport ANDROID_KEYSTORE_FILE="/path/to/keystore.jks"export ANDROID_KEYSTORE_PASSWORD="your-password"export ANDROID_KEY_ALIAS="your-alias"export ANDROID_KEY_PASSWORD="your-key-password"# Run packaging commandphp artisan native:package android --build-type=release --output=./artifacts --no-tty
#Common CI Workflows
#Development Pipeline
- Install dependencies:
composer install
- Setup environment: copy
.env
, generate key - Install NativePHP:
native:install android --force
- Build debug:
native:run android --build=debug --no-tty
#Release Pipeline
- Install dependencies:
composer install --no-dev --optimize-autoloader
- Setup environment with production settings
- Install NativePHP:
native:install android --force --with-icu
- Package release:
native:package android --build-type=release --no-tty
#Play Store Pipeline
- Same as release pipeline through step 3
- Package bundle:
native:package android --build-type=bundle --no-tty
- Upload to Play Console
#Error Handling
NativePHP commands provide proper exit codes for CI/CD:
0
: Success1
: General error- Build errors are logged and reported
Monitor build logs for:
- Compilation errors
- Signing failures
- Missing dependencies
- Permission issues
#Performance Tips
#Caching
Cache these directories in CI for faster builds:
vendor/
(Composer dependencies)nativephp/android/
(Android project)- Android SDK components
#Optimization
- Use
--no-dev
for production Composer installs - Enable Composer autoloader optimization
- Minimize included files with cleanup configuration
The --no-tty
flag and environment variable support make NativePHP Mobile well-suited for modern CI/CD pipelines, enabling fully automated mobile app builds and deployments.