PHP code example of aureuserp / nativephp-remote

1. Go to this page and download the library: Download aureuserp/nativephp-remote library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aureuserp / nativephp-remote example snippets


'start_url' => env('NATIVEPHP_START_URL', 'https://your-app.com/mobile?nativephp=1'),

use Webkul\NativephpRemote\Http\Middleware\PersistNativeShell;
use Webkul\NativephpRemote\Http\Middleware\RenderHostedNativeUi;

Route::middleware(['web', PersistNativeShell::class, RenderHostedNativeUi::class])
    ->group(function () {
        // Your routes here
    });

use Webkul\NativephpRemote\Support\NativeRemote;

// Check if the request is from a native app
NativeRemote::requestIsNative();

// Check if native navigation (top bar, side nav) should be rendered
NativeRemote::usesNativeNavigation();

// Check if the JS bridge (vibrate, toast) is available
NativeRemote::bridgeEnabled();

// Check if running in hosted remote mode
NativeRemote::usesHostedRemoteShell();

// Generate URLs that work in both native and web mode
NativeRemote::navigationUrl('my.route', ['param' => 1]);

// Generate a URL with a hash action (e.g., for triggering a scanner)
NativeRemote::hashActionUrl('scan-barcode');
// Returns: "https://your-app.com/current-page#scan-barcode"

// config/nativephp-remote.php

return [
    // Cookie name for native shell detection
    'cookie_name' => env('NATIVEPHP_REMOTE_COOKIE', 'nativephp_remote_shell'),

    // Cookie lifetime in minutes (default: 30 days)
    'cookie_lifetime' => 60 * 24 * 30,

    // Android permissions added during patching
    'android_permissions' => [
        'android.permission.CAMERA',
        'android.permission.VIBRATE',
    ],

    // iOS permission descriptions
    'ios_permissions' => [
        'NSCameraUsageDescription' => 'This app uses your camera to scan barcodes and QR codes.',
    ],
];
bash
php artisan vendor:publish --tag=nativephp-remote-config
bash
php artisan nativephp:patch-remote --force