Skip to main content
The Process API provides information about the current running process, including platform details and uptime.

Methods

arch()

Get the CPU architecture of the current process.
return
string
Returns the architecture: arm, arm64, ia32, x64, mips, ppc, or ppc64
use Native\Desktop\Facades\Process;

$arch = Process::arch();
// "x64" or "arm64"

platform()

Get the operating system platform.
return
string
Returns the platform: darwin (macOS), win32 (Windows), or linux
$platform = Process::platform();
// "darwin", "win32", or "linux"

uptime()

Get the number of seconds the process has been running.
return
float
Returns the uptime in seconds
$uptime = Process::uptime();
// 3600.5 (1 hour and 0.5 seconds)

fresh()

Get fresh process information as an object.
return
object
Returns an object with all process properties
$info = Process::fresh();
// object with arch, platform, uptime properties

Complete Examples

Platform Detection

use Native\Desktop\Facades\Process;

$platform = Process::platform();

match ($platform) {
    'darwin' => handleMacOS(),
    'win32' => handleWindows(),
    'linux' => handleLinux(),
};

Architecture-Specific Features

$arch = Process::arch();

if (in_array($arch, ['arm64', 'arm'])) {
    // Enable ARM-optimized features
    enableARMOptimizations();
}

Uptime Monitoring

$uptime = Process::uptime();

if ($uptime > 86400) { // 24 hours
    Notification::new()
        ->title('Long Session')
        ->message('Your app has been running for over 24 hours. Consider restarting.')
        ->show();
}

Combined Process Information

// Get all process info at once
$info = Process::fresh();

log_info('Process Information', [
    'architecture' => $info->arch,
    'platform' => $info->platform,
    'uptime' => $info->uptime,
]);

Platform-Specific Paths

use Native\Desktop\Facades\Process;

$platform = Process::platform();

$configPath = match ($platform) {
    'darwin' => '~/Library/Application Support',
    'win32' => getenv('APPDATA'),
    'linux' => '~/.config',
};

Platform Values

The platform() method returns one of these values:
  • darwin - macOS
  • win32 - Windows (both 32-bit and 64-bit)
  • linux - Linux

Architecture Values

The arch() method returns one of these values:
  • x64 - 64-bit Intel/AMD
  • arm64 - 64-bit ARM (Apple Silicon, etc.)
  • ia32 - 32-bit Intel/AMD
  • arm - 32-bit ARM
  • mips - MIPS architecture
  • ppc - PowerPC
  • ppc64 - 64-bit PowerPC

Use Cases

Platform Detection

Detect the operating system to show platform-specific UI or features

Architecture Checks

Optimize code paths based on CPU architecture (ARM vs x64)

Uptime Tracking

Monitor how long the app has been running for analytics or warnings

Path Resolution

Determine correct file paths for different platforms
The Process API provides runtime information about the Electron process, not the PHP process. This is useful for platform detection and architecture-specific optimizations.

Build docs developers (and LLMs) love