### Facade Usage Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Clipboard.md A concise example demonstrating how to use the Clipboard facade for common operations like setting text, getting text, and clearing the clipboard. ```php use Native\Laravel\Facades\Clipboard; Clipboard::text('Copy this to clipboard'); $text = Clipboard::text(); Clipboard::clear(); ``` -------------------------------- ### start() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts a new child process with the specified command, alias, and optional configuration. ```APIDOC ## start(string|array $cmd, string $alias, ?string $cwd = null, ?array $env = null, bool $persistent = false) ### Description Starts a new child process. ### Method POST ### Endpoint /child-process/start ### Parameters #### Request Body - **cmd** (string|array) - Required - Command to execute (string or array) - **alias** (string) - Required - Unique identifier for this process - **cwd** (string|null) - Optional - Working directory (defaults to base_path) - **env** (array|null) - Optional - Environment variables to pass - **persistent** (bool) - Optional - Whether process should persist across reloads ### Response #### Success Response (200) - **self** (object) - The started process instance ### Request Example ```php use Native\Laravel\Facades\ChildProcess; // Start with string command ChildProcess::start('npm run dev', 'npm-dev'); // Start with array command ChildProcess::start(['python', 'script.py'], 'python-script'); // Start with custom working directory ChildProcess::start( 'composer install', 'composer', cwd: base_path('packages/my-package') ); // Start persistent process ChildProcess::start( 'node server.js', 'node-server', persistent: true ); ``` ``` -------------------------------- ### Example: Create Menu with Label and Items Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md An example demonstrating how to create a menu, set its label, and add multiple menu items to it. ```php $menu = Menu::new() ->label('File') ->add($openItem) ->add($saveItem); ``` -------------------------------- ### start() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts a new child process. This is a general-purpose method for starting any executable. ```APIDOC ## start() ### Description Starts a new child process. ### Method Signature ```php public static function start(string $command, string $alias, ?array $env = null, ?bool $persistent = false, ?array $iniSettings = null): self ``` ### Parameters #### Path Parameters - **$command** (string) - Required - The command to execute - **$alias** (string) - Required - Unique identifier for this process - **$env** (array|null) - Optional - Environment variables - **$persistent** (bool) - Optional - Whether process persists (default: false) - **$iniSettings** (array|null) - Optional - PHP ini settings ### Returns - **self** - The started process instance ### Example ```php use Native\Laravel\Facades\ChildProcess; ChildProcess::start('npm run watch', 'npm-watch'); ``` ``` -------------------------------- ### Set and Get Settings Source: https://github.com/nativephp/laravel/blob/main/_autodocs/README.md Store and retrieve persistent key-value settings using the Settings facade. This example sets the theme to 'dark' and then retrieves it. ```php // Settings storage use Native\ Laravel\Facades\Settings; Settings::set('theme', 'dark'); $theme = Settings::get('theme'); ``` -------------------------------- ### Start Multiple Processes and Manage Them Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Demonstrates starting multiple distinct child processes (e.g., npm watch, artisan tinker) and managing them, including listing all and stopping specific ones. ```php ChildProcess::start('npm run watch', 'npm-watch'); ChildProcess::start('php artisan tinker', 'tinker'); // List all processes $processes = ChildProcess::all(); // Stop a specific process ChildProcess::stop('npm-watch'); ``` -------------------------------- ### Basic Process Start and Stop via Facade Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Illustrates the fundamental usage of the ChildProcess facade to start a Node.js server and then stop it. ```php use Native\Laravel\Facades\ChildProcess; ChildProcess::start('node server.js', 'node'); ChildProcess::stop('node'); ``` -------------------------------- ### Simple Notification Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Notification.md A basic example demonstrating how to create and display a simple notification with a title and message. ```php use Native\Laravel\Notification; Notification::new() ->title('Hello') ->message('This is a notification') ->show(); ``` -------------------------------- ### Full NativePHP Configuration Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/configuration.md A comprehensive example of the main configuration file, including app details, cloud storage, code signing, updater settings, and queue workers. ```php // config/nativephp.php return [ 'version' => env('NATIVEPHP_APP_VERSION', '1.0.0'), 'app_id' => env('NATIVEPHP_APP_ID', 'com.mycompany.myapp'), 'deeplink_scheme' => env('NATIVEPHP_DEEPLINK_SCHEME', 'myapp'), 'author' => env('NATIVEPHP_APP_AUTHOR', 'My Company'), 'copyright' => env('NATIVEPHP_APP_COPYRIGHT', '© 2024 My Company'), 'description' => env('NATIVEPHP_APP_DESCRIPTION', 'My awesome NativePHP app'), 'website' => env('NATIVEPHP_APP_WEBSITE', 'https://mycompany.com'), 'provider' => \App\Providers\NativeAppServiceProvider::class, 'cleanup_env_keys' => [ 'AWS_*', 'GITHUB_*', '*_SECRET', ], 'cleanup_exclude_files' => [ 'build', 'node_modules', '*/tests', ], 'updater' => [ 'enabled' => env('NATIVEPHP_UPDATER_ENABLED', true), 'default' => env('NATIVEPHP_UPDATER_PROVIDER', 'github'), 'providers' => [ 'github' => [ 'driver' => 'github', 'repo' => env('GITHUB_REPO'), 'owner' => env('GITHUB_OWNER'), 'token' => env('GITHUB_TOKEN'), ], ], ], 'queue_workers' => [ 'default' => [ 'queues' => ['default'], 'memory_limit' => 128, 'timeout' => 60, 'sleep' => 3, ], ], 'prebuild' => [], 'postbuild' => [], 'binary_path' => env('NATIVEPHP_PHP_BINARY_PATH', null), ]; ``` -------------------------------- ### Clipboard HTML Operations Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Clipboard.md Shows how to set and get HTML content from the system clipboard using the Clipboard facade. ```php Clipboard::html('
Rich HTML content
'); $html = Clipboard::html(); ``` -------------------------------- ### Monitor Update Progress and Install Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/AutoUpdater.md Shows how to listen for download progress events and handle the completion of the download, including prompting the user to restart and install the update. ```php use Native\Laravel\Facades\AutoUpdater; use Illuminate\Support\Facades\Event; // Listen for download progress Event::listen('updater.download-progress', function ($event) { $percent = ($event->progress / $event->total) * 100; ProgressBar::new()->setProgress($percent); }); // Listen for completion Event::listen('updater.update-downloaded', function () { ProgressBar::new()->finish(); // Prompt to install $result = Alert::new() ->title('Update Ready') ->detail('Restart to apply updates') ->buttons(['Restart Now', 'Later']) ->show(); if ($result === 0) { AutoUpdater::quitAndInstall(); } }); ``` -------------------------------- ### Notification with Action Buttons Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Notification.md Demonstrates how to add multiple action buttons to a notification. The example shows adding 'Open' and 'Show in Folder' buttons. ```php $notification = Notification::new() ->title('File Downloaded') ->message('document.pdf') ->reference('download-doc') ->addAction('Open') ->addAction('Show in Folder') ->show(); // Handle the action in your event listener // Listen for notification click events via the 'download-doc' reference ``` -------------------------------- ### Example: Build Application Menu Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md Demonstrates building a complete application menu with standard items, separators, and accelerators, then registering it. ```php use Native Laravel Menu Menu; use Native Laravel Menu Items MenuItem; use Native Laravel Menu Items Separator; use Native Laravel Menu Items Role; $menu = Menu::new() ->add( MenuItem::make('New') ->accelerator('CmdOrCtrl+N') ->event('file.new') ) ->add( MenuItem::make('Open') ->accelerator('CmdOrCtrl+O') ->event('file.open') ) ->add(Separator::make()) ->add( MenuItem::make('Exit') ->accelerator('CmdOrCtrl+Q') ->event('app.quit') ); $menu->register(); ``` -------------------------------- ### Example Usage: Setting Window URL Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Window.md Illustrates setting the URL that the window will load and display. ```php $window->url(route('dashboard')); ``` -------------------------------- ### Example Usage: Setting Window Dimensions Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Window.md Demonstrates setting the width and height of the window in pixels. ```php $window->width(1024); $window->height(768); ``` -------------------------------- ### Quit and Install Update Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Quits the application and proceeds with the installation of a downloaded update. ```APIDOC ## POST /auto-updater/quit-and-install ### Description Quits and installs update. ### Method POST ### Endpoint /auto-updater/quit-and-install ``` -------------------------------- ### php() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts a PHP script in a child process. This is a convenient wrapper for starting PHP scripts. ```APIDOC ## php() ### Description Starts a PHP script in a child process. ### Method Signature ```php public static function php( string $script, string $alias, ?array $env = null, ?bool $persistent = false, ?array $iniSettings = null ): self ``` ### Parameters #### Path Parameters - **$script** (string) - Required - The path to the PHP script to execute - **$alias** (string) - Required - Unique identifier for this process - **$env** (array|null) - Optional - Environment variables - **$persistent** (bool) - Optional - Whether process persists (default: false) - **$iniSettings** (array|null) - Optional - PHP ini settings ### Returns - **self** - The started process instance ### Example ```php use Native\Laravel\Facades\ChildProcess; ChildProcess::php( 'tasks/processor.php', 'task-processor', persistent: true, iniSettings: ['memory_limit' => '256M'] ); ``` ``` -------------------------------- ### Start Child Process Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Starts a new child process with specified command, working directory, and environment variables. The process is not persistent by default. ```json { "alias": "process-alias", "cmd": ["command", "arg1"], "cwd": "/path/to/dir", "env": {}, "persistent": false } ``` -------------------------------- ### Install Downloaded Update Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/AutoUpdater.md Quits the current application and installs the update that has already been downloaded. This is typically the final step in the update process. ```php use Native\Laravel\Facades\AutoUpdater; // Call this after update is downloaded AutoUpdater::quitAndInstall(); ``` -------------------------------- ### Example Usage: Window Initialization and ID Setting Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Window.md Demonstrates how to create a new window instance and then set its ID using the fluent interface. ```php $window = new Window('main')->id('settings'); ``` -------------------------------- ### Example: Add Menu Items Directly Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md Shows how to create a menu and add menu items directly using MenuItem::make. ```php use Native Laravel Menu Menu; use Native Laravel Menu Items MenuItem; $menu = Menu::new() ->add(MenuItem::make('Open')) ->add(MenuItem::make('Save')); ``` -------------------------------- ### Get Fresh Process Information Snapshot Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Process.md Fetches a fresh object containing the current 'arch', 'platform', and 'uptime' of the system. Use this to get an up-to-date overview of system process details. ```php use Native\Laravel\Facades\Process; $info = Process::fresh(); echo "Platform: {$info->platform}"; echo "Architecture: {$info->arch}"; echo "Uptime: {$info->uptime}"; ``` -------------------------------- ### Install NativePhp Laravel Source: https://github.com/nativephp/laravel/blob/main/_autodocs/README.md Install the NativePhp Laravel package using Composer. ```bash composer require nativephp/laravel ``` -------------------------------- ### Start PHP Child Process Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Starts a PHP child process, allowing configuration of PHP-specific settings like memory limits. ```json { "alias": "php-process", "cmd": ["script.php"], "cwd": "/path", "env": {}, "persistent": false, "iniSettings": {"memory_limit": "256M"} } ``` -------------------------------- ### Example: Register Context Menu Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md Shows how to create a simple context menu with basic items and register it using the ContextMenu facade. ```php use Native Laravel Menu Menu; use Native Laravel Menu Items MenuItem; use Native Laravel Facades ContextMenu; $menu = Menu::new() ->add(MenuItem::make('Open')) ->add(MenuItem::make('Edit')) ->add(MenuItem::make('Delete')); ContextMenu::register($menu); ``` -------------------------------- ### Example: Set Dock Menu (macOS) Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md Demonstrates how to define a dock menu for macOS applications using the Dock facade. ```php use Native Laravel Menu Menu; use Native Laravel Menu Items MenuItem; use Native Laravel Facades Dock; $menu = Menu::new() ->add(MenuItem::make('New Window')) ->add(MenuItem::make('Preferences')); Dock::menu($menu); ``` -------------------------------- ### php() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts a new PHP child process with the specified command, alias, and optional configuration. ```APIDOC ## php(string|array $cmd, string $alias, ?array $env = null, ?bool $persistent = false, ?array $iniSettings = null) ### Description Starts a PHP child process. ### Method POST ### Endpoint /child-process/php ### Parameters #### Request Body - **cmd** (string|array) - Required - PHP command(s) to execute - **alias** (string) - Required - Unique identifier for this process - **env** (array|null) - Optional - Environment variables - **persistent** (bool) - Optional - Whether process persists - **iniSettings** (array|null) - Optional - PHP ini settings ### Response #### Success Response (200) - **self** (object) - The started process instance ### Request Example ```php use Native\Laravel\Facades\ChildProcess; // Start PHP script ChildProcess::php('your-script.php', 'my-php-script'); // Start with custom ini settings ChildProcess::php( 'heavy-computation.php', 'cpu-intensive', iniSettings: [ 'memory_limit' => '512M', 'max_execution_time' => '0', ] ); // Start persistent process ChildProcess::php( 'websocket-server.php', 'websocket', persistent: true ); ``` ``` -------------------------------- ### Start Queue Worker with Options Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts a queue worker Artisan command with specific queue configurations and memory limit INI settings. ```php ChildProcess::artisan( ['queue:work', '--queue=default,priority'], 'queue-worker', persistent: true, iniSettings: ['memory_limit' => '512M'] ); ``` -------------------------------- ### Accessing System Facade Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/System.md Demonstrates how to use the System facade to access its methods, such as getting the theme or initiating a print job. ```php use Native Laravel\Facades\System; $theme = System::theme(); System::print($html); ``` -------------------------------- ### Example Usage: Setting Window Position Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Window.md Shows how to set the specific X and Y coordinates for the window's position on the screen. ```php $window->position(100, 100); ``` -------------------------------- ### Start Background Task Runner Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts a background task processor using PHP, with specified INI settings. The process is set to persist. ```php use Native\Laravel\Facades\ChildProcess; // Start background task ChildProcess::php( 'tasks/processor.php', 'task-processor', persistent: true, iniSettings: ['memory_limit' => '256M'] ); // Later, stop the processor ChildProcess::stop('task-processor'); ``` -------------------------------- ### Notification with Event Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Notification.md Example of creating a notification that triggers a specific event upon interaction. It includes setting a reference, title, message, and the event name. ```php Notification::new() ->reference('task-completed-123') ->title('Task Completed') ->message('Your task is finished') ->event('task.completed') ->show(); ``` -------------------------------- ### Example Usage: Setting Window Title Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Window.md Shows how to set the title of the window using the title() method. ```php $window->title('My Application'); ``` -------------------------------- ### Start a PHP Child Process Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Specifically designed to start a PHP child process. Allows configuration of environment variables, persistence, and custom PHP ini settings for the child process. ```php use Native\Laravel\Facades\ChildProcess; // Start PHP script ChildProcess::php('your-script.php', 'my-php-script'); // Start with custom ini settings ChildProcess::php( 'heavy-computation.php', 'cpu-intensive', iniSettings: [ 'memory_limit' => '512M', 'max_execution_time' => '0', ] ); // Start persistent process ChildProcess::php( 'websocket-server.php', 'websocket', persistent: true ); ``` -------------------------------- ### Storing User Preferences Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Settings.md Demonstrates saving and retrieving multiple user preferences like window dimensions and UI visibility. ```php use Native\Laravel\Facades\Settings; // Save preferences Settings::set('window_width', 1024); Settings::set('window_height', 768); Settings::set('sidebar_visible', true); // Retrieve preferences $width = Settings::get('window_width', 800); $height = Settings::get('window_height', 600); $showSidebar = Settings::get('sidebar_visible', true); ``` -------------------------------- ### Start Artisan Command Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Starts an Artisan command in a child process. Use the 'persistent' option for long-running commands like queue workers. ```php use Native\Laravel\Facades\ChildProcess; // Start Artisan command ChildProcess::artisan('queue:work', 'queue-worker', persistent: true); // Start with options ChildProcess::artisan( ['optimize:clear'], 'optimize' ); ``` -------------------------------- ### Get a Setting Value Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Settings.md Use the `get` method to retrieve a setting's value by its key. You can provide a default value that will be returned if the key does not exist. Closures can be used for dynamic default values. ```php use Native\Laravel\Facades\Settings; $name = Settings::get('user_name'); // null if not set $theme = Settings::get('theme', 'light'); // 'light' if not set // Using closure for dynamic defaults $version = Settings::get('app_version', fn() => '1.0.0'); ``` -------------------------------- ### Instantiate Notification Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Notification.md Use `Notification::new()` to create a new notification instance. This is the recommended way to start building a notification. ```php use Native\Laravel\Notification; $notification = Notification::new(); ``` -------------------------------- ### all() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/ChildProcess.md Gets all currently running child processes managed by the system. ```APIDOC ## all() ### Description Gets all running child processes. ### Method GET ### Endpoint /child-processes ### Parameters None ### Response #### Success Response (200) - **array** (object) - Associative array of processes (alias => ChildProcess) ### Request Example ```php use Native\Laravel\Facades\ChildProcess; $processes = ChildProcess::all(); foreach ($processes as $alias => $process) { echo "$alias: PID {$process->pid}"; } ``` ``` -------------------------------- ### Example Usage: Disabling Window Resizing Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Window.md Illustrates how to make the window non-resizable by setting the resizable parameter to false. ```php $window->resizable(false); // Fixed size ``` -------------------------------- ### get() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/WindowManager.md Retrieves a specific window instance by its unique ID. ```APIDOC ## get() ### Description Gets a specific window by ID. ### Method `public function get(string $id): Window` ### Parameters #### Path Parameters - **$id** (string) - Required - The window ID. ### Returns `Window` - The window instance. ### Example ```php use Native\\\Laravel\\ Facades\\ Window; $settings = Window::get('settings'); ``` ``` -------------------------------- ### Using ThermalStatesEnum Source: https://github.com/nativephp/laravel/blob/main/_autodocs/types.md Illustrates how to get the current thermal state and use a match expression to handle different states, such as critical or serious heat levels. ```php use Native\Laravel\Facades\PowerMonitor; use Native\Laravel\Enums\ThermalStatesEnum; $thermal = PowerMonitor::getCurrentThermalState(); match($thermal) { ThermalStatesEnum::CRITICAL => log('Critical!'), ThermalStatesEnum::SERIOUS => log('Hot'), default => null, }; ``` -------------------------------- ### Open and Configure a Window Source: https://github.com/nativephp/laravel/blob/main/_autodocs/README.md This example demonstrates using a fluent interface to open a window, set its title, dimensions, and resizable property before finally opening it. This is the standard way to create and manage application windows. ```php Window::open('settings') ->title('Settings') ->width(600) ->height(400) ->resizable(false) ->open(); ``` -------------------------------- ### Clipboard Image Operations Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Clipboard.md Illustrates copying an image file or data URI to the clipboard, and retrieving an image from the clipboard. ```php // Copy image file to clipboard Clipboard::image(storage_path('images/screenshot.png')); // Copy image from data URI $dataUri = 'data:image/png;base64,iVBORw0KGgoAAAANS...'; Clipboard::image($dataUri); // Paste image from clipboard $image = Clipboard::image(); if ($image) { // Process the image } ``` -------------------------------- ### Get System Theme Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Retrieves the current system theme setting (e.g., 'dark' or 'light'). ```json { "result": "dark" } ``` -------------------------------- ### Updater Configuration Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/AutoUpdater.md Illustrates the configuration structure for the NativePHP updater, including enabling the updater and specifying different provider options like GitHub, S3, or Spaces. ```php 'updater' => [ 'enabled' => env('NATIVEPHP_UPDATER_ENABLED', true), 'default' => env('NATIVEPHP_UPDATER_PROVIDER', 'spaces'), 'providers' => [ 'github' => [ 'driver' => 'github', 'repo' => env('GITHUB_REPO'), 'owner' => env('GITHUB_OWNER'), 'token' => env('GITHUB_TOKEN'), ], 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), ], 'spaces' => [ 'driver' => 'spaces', 'key' => env('DO_SPACES_KEY_ID'), 'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'), 'name' => env('DO_SPACES_NAME'), 'region' => env('DO_SPACES_REGION'), ], ], ], ``` -------------------------------- ### Prebuild Commands Configuration Source: https://github.com/nativephp/laravel/blob/main/_autodocs/configuration.md Specify commands to execute before the application is bundled for distribution. This is useful for tasks like transpiling or dependency installation. ```php 'prebuild' => [ // 'npm run build', ], ``` -------------------------------- ### Get Application Version Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/App.md Retrieves the current version of the application. Returns a string representing the version. ```php use Native Laravel Facades App; echo App::version(); // e.g., '1.0.0' ``` -------------------------------- ### AutoUpdater::quitAndInstall() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/AutoUpdater.md Quits the current application and installs the downloaded update. This is the final step in the update process. ```APIDOC ## AutoUpdater::quitAndInstall() ### Description Quits the application and installs the downloaded update. This method should be called after the update has been successfully downloaded. ### Method `AutoUpdater::quitAndInstall()` ### Parameters None ### Returns `void` ### Example ```php use Native\\\Laravel\\Facades\\AutoUpdater; // Call this after update is downloaded AutoUpdater::quitAndInstall(); ``` ``` -------------------------------- ### Instantiate Alert Class Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Alert.md Use `Alert::new()` to create a new instance of the Alert class. This is the recommended way to start building an alert. ```php use Native\Laravel\Alert; $alert = Alert::new(); ``` -------------------------------- ### Default Values with Closures for Settings Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Settings.md Demonstrates using closures with the `get` method to provide dynamic default values for settings, which can be useful for expensive computations. ```php use Native\Laravel\Facades\Settings; // Dynamic default $maxConnections = Settings::get('max_connections', fn() => 10); // This is useful for expensive computations $cacheSize = Settings::get('cache_size', fn() => calculateOptimalSize()); ``` -------------------------------- ### Platform-Specific Configuration Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Process.md Configures application settings based on the operating system platform. This snippet demonstrates conditional configuration for macOS, Windows, and Linux. ```php use Native\Laravel\Facades\Process; if (Process::platform() === 'darwin') { // macOS specific settings config(['app.platform' => 'macos']); } else if (Process::platform() === 'win32') { // Windows specific settings config(['app.platform' => 'windows']); } else { // Linux config(['app.platform' => 'linux']); } ``` -------------------------------- ### Example: Create Submenu Structure Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md Illustrates creating nested menus, including a main menu with submenus for 'Edit' and 'File' operations, and a nested submenu for export formats. ```php use Native Laravel Menu Menu; use Native Laravel Menu Items MenuItem; $editMenu = Menu::new('Edit') ->add(MenuItem::make('Undo')) ->add(MenuItem::make('Redo')) ->add(MenuItem::make('Cut')) ->add(MenuItem::make('Copy')) ->add(MenuItem::make('Paste')); $fileMenu = Menu::new('File') ->add(MenuItem::make('Open')) ->add(MenuItem::make('Save')) ->add( MenuItem::make('Export') ->submenu( MenuItem::make('PDF'), MenuItem::make('PNG'), MenuItem::make('SVG') ) ); ``` -------------------------------- ### Instantiate Dialog Class Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Dialog.md Use the static `new()` method to create a new instance of the Dialog class. This is the recommended way to start building dialog configurations. ```php use Native\Laravel\Dialog; $dialog = Dialog::new(); ``` -------------------------------- ### Get Current Thermal State Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Gets the current thermal state of the system. The response will indicate the thermal condition, such as 'nominal'. ```json { "result": "nominal" } ``` -------------------------------- ### GET /window/all Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Retrieves information about all currently open windows. This is part of the Window Management endpoints. ```APIDOC ## GET /window/all ### Description Gets all open windows. ### Method GET ### Endpoint /window/all ### Response #### Success Response (200) Returns an array of objects, where each object represents an open window. - **id** (string) - The ID of the window. - **title** (string) - The title of the window. - ... (other properties may be included) ``` -------------------------------- ### Automatic Update Check on Startup Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/AutoUpdater.md Configures the application to automatically check for updates when the application starts, based on a configuration setting. ```php // In NativeAppServiceProvider use Native\Laravel\Facades\AutoUpdater; class NativeAppServiceProvider extends ServiceProvider { public function boot(): void { if (config('app.check_updates')) { AutoUpdater::checkForUpdates(); } } } ``` -------------------------------- ### theme() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/System.md Gets or sets the system theme. This method can be used to retrieve the current theme or set a new theme. ```APIDOC ## theme(?SystemThemesEnum $theme = null) ### Description Gets or sets the system theme. ### Method ```php public function theme(?SystemThemesEnum $theme = null): SystemThemesEnum ``` ### Parameters #### Path Parameters - **$theme** (SystemThemesEnum|null) - Optional - Theme to set, or null to get current ### Returns `SystemThemesEnum` - The current theme ### Request Example ```php use Native\Laravel\Facades\System; use Native\Laravel\Enums\SystemThemesEnum; // Get current theme $theme = System::theme(); // Set theme System::theme(SystemThemesEnum::DARK); System::theme(SystemThemesEnum::LIGHT); System::theme(SystemThemesEnum::SYSTEM); ``` ``` -------------------------------- ### Clipboard Text Operations Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Clipboard.md Demonstrates common text operations using the Clipboard facade, including copying text, reading text, and clearing the clipboard. ```php use Native\Laravel\Facades\Clipboard; // Copy text to clipboard Clipboard::text('This is my text'); // Read from clipboard $content = Clipboard::text(); // Clear clipboard Clipboard::clear(); ``` -------------------------------- ### Open and Configure a Window Source: https://github.com/nativephp/laravel/blob/main/_autodocs/README.md Use the Window facade to open a new application window, set its title, URL, and dimensions. ```php // Window management use Native\Laravel\Facades\Window; Window::open('main') ->title('My App') ->url(url('/')) ->width(1024) ->height(768) ->open(); ``` -------------------------------- ### System Information Display Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Process.md Displays detailed system information including platform, architecture, and uptime in a human-readable format. It uses mapping arrays to translate technical values into user-friendly descriptions. ```php use Native\Laravel\Facades\Process; $info = Process::fresh(); $platforms = [ 'darwin' => 'macOS', 'win32' => 'Windows', 'linux' => 'Linux', ]; $architectures = [ 'x64' => '64-bit Intel', 'arm64' => '64-bit ARM', 'ia32' => '32-bit Intel', ]; echo "Running on: " . ($platforms[$info->platform] ?? $info->platform); echo "Architecture: " . ($architectures[$info->arch] ?? $info->arch); echo "System Uptime: " . gmdate('H:i:s', $info->uptime); ``` -------------------------------- ### Display Object Structure Example Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Screen.md Illustrates the structure of a display information object, detailing properties like 'id', 'bounds', 'workArea', 'scaleFactor', and 'rotation'. ```php [ 'id' => 'display-id', 'bounds' => [ 'x' => 0, 'y' => 0, 'width' => 1920, 'height' => 1080, ], 'workArea' => [ 'x' => 0, 'y' => 25, 'width' => 1920, 'height' => 1055, ], 'scaleFactor' => 1.0, // Device pixel ratio 'rotation' => 0, // Rotation in degrees 'monochrome' => false, ] ``` -------------------------------- ### Accessing the Dock Facade Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Dock.md Use the Dock facade to access its methods. This example shows common method calls for setting the menu, badge, bounce, icon, and controlling visibility. ```php use Native\Laravel\Facades\Dock; Dock::menu($menu); Dock::badge('5'); Dock::bounce('critical'); Dock::cancelBounce(); Dock::icon($path); Dock::show(); Dock::hide(); ``` -------------------------------- ### Get System Theme and Printers Source: https://github.com/nativephp/laravel/blob/main/_autodocs/README.md Retrieve the current system theme and a list of available printers using the System facade. ```php // System operations use Native\ Laravel\Facades\System; $theme = System::theme(); $printers = System::printers(); ``` -------------------------------- ### Get All Open Window Information Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Fetches an array containing information for all currently open windows. Each object in the array represents a window with its properties. ```http GET /window/all ``` -------------------------------- ### Menu Facade Usage Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Menu.md Demonstrates how to create a menu instance using the Menu facade and register it. ```APIDOC ## Menu Facade Access this class via the `Menu` facade: ```php use Native\Laravel\Facades\Menu; $menu = Menu::make( Menu\Items\MenuItem::make('Open'), Menu\Items\MenuItem::make('Save') ); Menu::register($menu); ``` ``` -------------------------------- ### Get or Set Application Badge Count Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/App.md Gets the current badge count or sets a new count for the application's dock/taskbar icon. Returns the current badge count as an integer. ```php use Native Laravel Facades App; // Get current badge count $count = App::badgeCount(); // Set badge count App::badgeCount(5); ``` -------------------------------- ### Show an Alert Message Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Alert.md Use the Alert facade to display a simple 'Hello World' message. Ensure the facade is imported before use. ```php use Native\Laravel\Facades\Alert; Alert::show('Hello World'); ``` -------------------------------- ### Get or Set Clipboard Text Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/Clipboard.md This method can be used to retrieve the current text content of the clipboard or set new text. Pass text content as an argument to set it, or call without arguments to get the current text. ```php use Native\Laravel\Facades\Clipboard; // Get clipboard text $text = Clipboard::text(); // Set clipboard text Clipboard::text('Hello, World!'); ``` -------------------------------- ### Using PowerStatesEnum Source: https://github.com/nativephp/laravel/blob/main/_autodocs/types.md Demonstrates listening for power state changes and reacting when the system switches to battery power. This allows for adaptive behavior, like reducing resource consumption. ```php use Native\Laravel\Enums\PowerStatesEnum; use Illuminate\Support\Facades\Event; Event::listen('power-state-changed', function ($event) { if ($event->state === PowerStatesEnum::BATTERY) { // Switch to battery mode } }); ``` -------------------------------- ### Platform-Specific Shortcut Registration Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/GlobalShortcut.md This example demonstrates how to register different shortcuts based on the operating system. It uses `Process::platform()` to detect the OS and applies macOS-specific or Windows/Linux-specific shortcuts accordingly. ```php use Native\\Laravel\\Facades\\GlobalShortcut; use Native\\Laravel\\Facades\\Process; $platform = Process::platform(); if ($platform === 'darwin') { // macOS-specific shortcut GlobalShortcut::key('Cmd+Option+D') ->event('debug.toggle') ->register(); } else { // Windows/Linux shortcut GlobalShortcut::key('Ctrl+Alt+D') ->event('debug.toggle') ->register(); } ``` -------------------------------- ### getSystemIdleTime Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/PowerMonitor.md Gets the total time the system has been idle in seconds. ```APIDOC ## getSystemIdleTime() ### Description Gets the time the system has been idle. ### Method ```php public function getSystemIdleTime(): int ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response - **int** - Idle time in seconds ### Example ```php use Native\ Laravel\ Facades\ PowerMonitor; $idleSeconds = PowerMonitor::getSystemIdleTime(); $idleMinutes = (int)($idleSeconds / 60); echo "System idle for: {$idleMinutes} minutes"; ``` ``` -------------------------------- ### Basic Update Flow with User Prompt Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/AutoUpdater.md Demonstrates a common update flow where the application listens for an 'update-available' event, prompts the user, and initiates the download upon user confirmation. ```php use Native\Laravel\Facades\AutoUpdater; use Illuminate\Support\Facades\Event; // Listen for update available event Event::listen('updater.update-available', function ($event) { // Prompt user Notification::new() ->title('Update Available') ->message("Version {$event->version} is available") ->addAction('Update Now') ->addAction('Later') ->show(); }); // User clicks "Update Now" AutoUpdater::downloadUpdate(); ``` -------------------------------- ### Listening to Global Shortcut Events Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/GlobalShortcut.md This example illustrates how to listen for the events dispatched by global shortcuts using Laravel's `Event::listen()` facade. This allows you to execute specific logic when a shortcut is triggered. ```php use Illuminate\\Support\\Facades\\Event; Event::listen('shortcut.activate-search', function () { // Handle the search shortcut }); Event::listen('debug.toggle', function () { // Toggle debug mode }); ``` -------------------------------- ### Child Process Management Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Endpoints for starting, managing, and communicating with child processes. ```APIDOC ## POST /child-process/start ### Description Starts a new child process. ### Method POST ### Endpoint /child-process/start ### Request Body - **alias** (string) - Required - An alias for the child process. - **cmd** (array) - Required - The command and its arguments to execute. - **cwd** (string) - Optional - The working directory for the process. - **env** (object) - Optional - Environment variables for the process. - **persistent** (boolean) - Optional - Whether the process should be kept alive. ### Request Example { "alias": "process-alias", "cmd": ["command", "arg1"], "cwd": "/path/to/dir", "env": {}, "persistent": false } ``` ```APIDOC ## POST /child-process/start-php ### Description Starts a new PHP child process. ### Method POST ### Endpoint /child-process/start-php ### Request Body - **alias** (string) - Required - An alias for the PHP process. - **cmd** (array) - Required - The PHP script and its arguments to execute. - **cwd** (string) - Optional - The working directory for the process. - **env** (object) - Optional - Environment variables for the process. - **persistent** (boolean) - Optional - Whether the process should be kept alive. - **iniSettings** (object) - Optional - PHP INI settings to apply. ### Request Example { "alias": "php-process", "cmd": ["script.php"], "cwd": "/path", "env": {}, "persistent": false, "iniSettings": {"memory_limit": "256M"} } ``` ```APIDOC ## GET /child-process/get/{alias} ### Description Retrieves information about a specific child process by its alias. ### Method GET ### Endpoint /child-process/get/{alias} ### Parameters #### Path Parameters - **alias** (string) - Required - The alias of the child process to retrieve. ``` ```APIDOC ## GET /child-process/ ### Description Retrieves a list of all active child processes. ### Method GET ### Endpoint /child-process/ ``` ```APIDOC ## POST /child-process/stop ### Description Stops a running child process. ### Method POST ### Endpoint /child-process/stop ### Request Body - **alias** (string) - Required - The alias of the child process to stop. ### Request Example { "alias": "process-alias" } ``` ```APIDOC ## POST /child-process/restart ### Description Restarts a running child process. ### Method POST ### Endpoint /child-process/restart ### Request Body - **alias** (string) - Required - The alias of the child process to restart. ### Request Example { "alias": "process-alias" } ``` ```APIDOC ## POST /child-process/message ### Description Sends a message to a running child process. ### Method POST ### Endpoint /child-process/message ### Request Body - **alias** (string) - Required - The alias of the target child process. - **message** (string) - Required - The message content to send. ### Request Example { "alias": "process-alias", "message": "message content" } ``` -------------------------------- ### open() Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/WindowManager.md Opens a new window or returns a pending window builder for configuration. If no ID is provided, it defaults to 'main'. ```APIDOC ## open() ### Description Opens a new window or returns a pending window builder for configuration. ### Method `public function open(string $id = 'main')` ### Parameters #### Path Parameters - **$id** (string) - Optional - Unique identifier for the window. Defaults to 'main'. ### Returns `PendingOpenWindow` - A fluent window builder for configuration. ### Example ```php use Native\Laravel\Facades\Window; Window::open('settings') ->title('Settings') ->url(route('settings')) ->width(600) ->height(400) ->open(); ``` ``` -------------------------------- ### Get Current Thermal State Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Retrieves the current thermal state of the system. ```APIDOC ## GET /power-monitor/get-current-thermal-state ### Description Gets thermal state. ### Method GET ### Endpoint /power-monitor/get-current-thermal-state ### Response #### Success Response (200) - **result** (string) - The current thermal state (e.g., "nominal") #### Response Example { "result": "nominal" } ``` -------------------------------- ### System Theme Operations Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Endpoints for getting and setting the system's theme. ```APIDOC ## GET /system/theme ### Description Retrieves the current system theme. ### Method GET ### Endpoint /system/theme ### Response #### Success Response (200) - **result** (string) - The current theme (e.g., 'dark', 'light'). ### Response Example { "result": "dark" } ``` ```APIDOC ## POST /system/theme ### Description Sets the system theme. ### Method POST ### Endpoint /system/theme ### Request Body - **theme** (string) - Required - The theme to set (e.g., 'dark', 'light'). ### Request Example { "theme": "dark" } ``` -------------------------------- ### Using SystemThemesEnum Source: https://github.com/nativephp/laravel/blob/main/_autodocs/types.md Demonstrates how to set the system theme using the SystemThemesEnum with the Native Laravel Facades System. ```php use Native\Laravel\Facades\System; use Native\Laravel\Enums\SystemThemesEnum; $theme = System::theme(SystemThemesEnum::DARK); ``` -------------------------------- ### Clipboard Text Operations Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Endpoints for setting and getting text from the system clipboard. ```APIDOC ## POST /clipboard/text ### Description Sets the text content of the system clipboard. ### Method POST ### Endpoint /clipboard/text ### Request Body - **text** (string) - Required - The text to set on the clipboard. ### Request Example { "text": "new text" } ``` ```APIDOC ## GET /clipboard/text ### Description Gets the current text content from the system clipboard. ### Method GET ### Endpoint /clipboard/text ### Response #### Success Response (200) - **text** (string) - The text content of the clipboard. ### Response Example { "text": "clipboard content" } ``` -------------------------------- ### Get Active Display Information Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Retrieves the bounds of the currently active display. ```json { "bounds": {"x": 0, "y": 0, "width": 1920, "height": 1080} } ``` -------------------------------- ### Clipboard Image Operations Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Endpoints for setting and getting image data from the system clipboard. ```APIDOC ## GET /clipboard/image ### Description Gets the current image data from the system clipboard. ### Method GET ### Endpoint /clipboard/image ### Response #### Success Response (200) - **image** (string) - The base64 encoded image data of the clipboard. ### Response Example { "image": "data:image/png;base64,..." } ``` ```APIDOC ## POST /clipboard/image ### Description Sets the image data of the system clipboard. ### Method POST ### Endpoint /clipboard/image ### Request Body - **image** (string) - Required - The base64 encoded image data to set on the clipboard. ### Request Example { "image": "data:image/png;base64,..." } ``` -------------------------------- ### Clipboard HTML Operations Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Endpoints for setting and getting HTML content from the system clipboard. ```APIDOC ## GET /clipboard/html ### Description Gets the current HTML content from the system clipboard. ### Method GET ### Endpoint /clipboard/html ### Response #### Success Response (200) - **html** (string) - The HTML content of the clipboard. ### Response Example { "html": "

HTML content

" } ``` ```APIDOC ## POST /clipboard/html ### Description Sets the HTML content of the system clipboard. ### Method POST ### Endpoint /clipboard/html ### Request Body - **html** (string) - Required - The HTML content to set on the clipboard. ### Request Example { "html": "

HTML

" } ``` -------------------------------- ### Relaunch the Application Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/App.md Use this method to relaunch the application. It takes no parameters and returns void. ```php use Native Laravel Facades App; App::relaunch(); ``` -------------------------------- ### Get Primary Display Information Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Retrieves details about the primary display connected to the system. ```json { "primaryDisplay": {...} } ``` -------------------------------- ### Use Window Facade for Actions Source: https://github.com/nativephp/laravel/blob/main/_autodocs/README.md This snippet shows how to use the `Window` facade to perform actions like maximizing the current window. Facades provide convenient, static access to major framework features. ```php use Native\Laravel\Facades\Window; Window::maximize(); ``` -------------------------------- ### Get Cursor Position Source: https://github.com/nativephp/laravel/blob/main/_autodocs/endpoints.md Retrieves the current X and Y coordinates of the mouse cursor on the screen. ```json { "x": 100, "y": 200 } ``` -------------------------------- ### Access App Class via Facade Source: https://github.com/nativephp/laravel/blob/main/_autodocs/api-reference/App.md Demonstrates how to use the App facade to access its methods, such as retrieving the application version. ```php use Native\\Laravel\\Facades\\App; App::version(); ```