NativePHP for Laravel
repository·main·Indexed 26 days ago
https://github.com/nativephp/laravelA Laravel wrapper for the NativePHP framework that enables developers to build native desktop applications using PHP. It provides facades for managing application window state, system alerts, auto-updates, and child processes, along with Artisan commands for database migrations, seeding, and debugging in a desktop environment. Note: This repository is archived; active development has moved to nativephp/desktop.
What's inside nativephp-laravel
- NativePHP is a Laravel wrapper that allows you to write native desktop applications using PHP. It enables developers to leverage their existing Laravel knowledge to build applications that run on desktop environments.
Important: This repository is archived
mainThis repository (nativephp/laravel) is archived. Development has moved to nativephp/desktop. Users should migrate to or use the new repository for active development.Configure the NativePHP internal API client
mainThe
Clientclass relies on thenativephp-internalconfiguration keys to establish connection settings. Ensure these are set in your Laravel configuration to allow the client to authenticate and locate the runtime API.Required configuration keys:
nativephp-internal.api_url: The base URL for the NativePHP internal API.nativephp-internal.secret: The secret key used for theX-NativePHP-Secretheader.
Manage application badge count
mainThe
badgeCount()method allows you to both retrieve and set the application's badge count (the number displayed on the dock icon).- To get the current count: Call
$app->badgeCount()with no arguments. - To set a new count: Call
$app->badgeCount($count)where$countis an integer.
- To get the current count: Call
Manage child processes via the ChildProcess facade
mainTheNative\Laravel\Facades\ChildProcessfacade provides a high-level API for starting, managing, and interacting with child processes within your NativePHP application. You can use it to run arbitrary commands, PHP scripts, or Artisan commands as background processes.Fake child processes for testing
mainTo test code that interacts with child processes without actually spawning real processes, use thefake()method on theChildProcessfacade. This swaps the real implementation with aChildProcessFakeinstance.Check and prompt for Touch ID
mainUse theSystemclass to interact with biometric authentication. You can check if the system supports Touch ID prompting and then trigger a prompt by providing a reason string.Manage recent documents
mainManage the list of recently opened documents in your application:
addRecentDocument(string $path): Adds a file path to the recent documents list.recentDocuments(): Returns an array of document paths.clearRecentDocuments(): Clears the entire recent documents list.
Use the Client class to interact with the NativePHP runtime
mainThe
Native\Laravel\Client\Clientclass provides a wrapper around Laravel's HTTP client to facilitate communication with the NativePHP internal API. It automatically configures the base URL, a 1-hour timeout, and the requiredX-NativePHP-Secretheader using settings from thenativephp-internalconfiguration file.Available methods:
get(string $endpoint, array|string|null $query = null): Response- Performs a GET request to the specified endpoint.post(string $endpoint, array $data = []): Response- Performs a POST request to the specified endpoint with the provided data.delete(string $endpoint, array $data = []): Response- Performs a DELETE request to the specified endpoint with the provided data.
Control application window state with App
mainUse theNative\Laravel\Appclass to manage the visibility and focus of your application window. You can quit the application, relaunch it, focus the window, or hide it.Access system locale and version information via the App facade
mainUse theNative\Laravel\Facades\Appfacade to retrieve information about the application's version and the system's locale settings.Use the Emoji Panel
mainIf the platform supports it, you can interact with the system emoji panel:
isEmojiPanelSupported(): Returns a boolean indicating if the emoji panel can be shown.showEmojiPanel(): Triggers the display of the emoji panel.