Skip to content

Installation

Requirements

  • PHP 8.4 or later
  • NativePHP Mobile 4.1 or a compatible later 4.x release
  • Android API 29+, or iOS 18+
  • A running NativePHP mobile application for real requests

Install and register

bash
composer require victorycodedev/nativephp-fetch
php artisan native:plugin:register victorycodedev/nativephp-fetch

If the NativePHP plugin provider has not been published in your application:

bash
php artisan vendor:publish --tag=nativephp-plugins-provider

Verify registration and rebuild your native app:

bash
php artisan native:plugin:list
php artisan native:run

NativePHP's official Using Plugins guide explains registration, rebuilding, permissions, and removing plugins.

How requests work

Fetch starts networking natively and returns a request ID. It does not wait for or return the HTTP response.

php
use Victorycodedev\NativephpFetch\Facades\Fetch;

$request = Fetch::acceptJson()->timeout(30);
$requestId = $request->id();
$returnedId = $request->get('https://api.example.com/users');

$requestId and $returnedId are the same. Store the ID before starting work so even a very fast event can be correlated with the correct request.

Runtime scope

Fetch requires the running NativePHP mobile bridge. Do not use it in queued jobs, scheduled tasks, CLI commands, or server-side code without a live mobile runtime. Use Laravel's normal HTTP client in those environments:

php
use Illuminate\Support\Facades\Http;

$response = Http::post($url, $data);

Released under the MIT License.