NativePHP for Laravel

repository·main·Indexed 26 days ago

https://github.com/nativephp/laravel

A 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.

Tokens
3.3K
Snippets
1
Records
39
Agent score
87%

What's inside nativephp-laravel

  1. Use NativePHP for Laravel to build desktop applications

    main
    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.
  2. Configure the NativePHP internal API client

    main

    The Client class relies on the nativephp-internal configuration 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 the X-NativePHP-Secret header.
  3. Manage application badge count

    main

    The 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 $count is an integer.
  4. Manage child processes via the ChildProcess facade

    main
    The Native\Laravel\Facades\ChildProcess facade 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.
  5. Manage recent documents

    main

    Manage 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.
  6. Use the Client class to interact with the NativePHP runtime

    main

    The Native\Laravel\Client\Client class 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 required X-NativePHP-Secret header using settings from the nativephp-internal configuration 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.
  7. Use the Emoji Panel

    main

    If 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.