feat: Add native splash screen support via Electron#112
Open
Nexus633 wants to merge 4 commits into
Open
Conversation
added 3 commits
May 13, 2026 16:17
…iately on app ready. - Bypasses the "dead zone" while the PHP binary and Laravel framework are booting. - Added a `splash.js` module to handle .env parsing and window management. - Configuration is handled via .env variables for toggle, dimensions, and custom HTML paths.
…ly on app startup. - Fixes the "empty space" issue where the app appears non-responsive while the PHP binary and Laravel framework are booting. - Implements robust .env parsing on the Electron side using process.env. - Adds intelligent closing logic that waits for the local Laravel URL (did-navigate) to ensure the main UI is ready. - Support for both development and production (packaged) environments.
…ata directory in packaged environments. - Implements app.isPackaged check for reliable path resolution within and outside the ASAR archive. - Updates closing logic to use the 'did-navigate' event filtered by the local PHP server URL. - This prevents premature dismissal of the splash screen by background installer or update processes. - Ensures window dimensions are cast to integers to satisfy Electron API requirements. - Replaced UI error dialogs with silent console logging for production-ready error handling.
Author
fix: Resolve splash screen visibility and lifecycle in production builds📂 The Problem (Why the previous version failed)The initial implementation of the splash screen worked in development but encountered two critical issues once the application was packaged and installed:
✨ The FixThis PR provides a robust update to ensure the splash screen is visible and functions correctly in all environments. Technical Improvements:
⚙️ Configuration (.env)The configuration remains consistent with the previous iteration: NATIVEPHP_SPLASH_ENABLED=true
NATIVEPHP_SPLASH_WIDTH=400
NATIVEPHP_SPLASH_HEIGHT=300
NATIVEPHP_SPLASH_HTML="public/splash.html"📂 Implementation Details
✅ Checklist
|
…ata directory in packaged environments. - Implements app.isPackaged check for reliable path resolution within and outside the ASAR archive. - Updates closing logic to use the 'did-navigate' event filtered by the local PHP server URL. - This prevents premature dismissal of the splash screen by background installer or update processes. - Ensures window dimensions are cast to integers to satisfy Electron API requirements. - Replaced UI error dialogs with silent console logging for production-ready error handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 The Problem
Currently, there is a significant "dead zone" (especially on Windows) between launching the application
.exeand the first window appearing. This is because NativePHP must first initialize the PHP binary, start the local server, and boot the Laravel framework before any window can be opened via theNativeAppServiceProvider.On some systems, this leads to several seconds of "silence" where the user might think the application didn't start.
✨ The Solution
This PR introduces a native Electron splash screen that triggers immediately after the Electron process starts, providing instant visual feedback.
Since it runs in the Electron main process, it doesn't wait for PHP to be ready. It includes a robust
.envparser that works in both development (vendor context) and production environments.🛠 Key Features
.envfile regardless of the directory depth (Dev vs. Prod).⚙️ Configuration
Users can customize the behavior by adding these keys to their
.envfile:📂 Implementation Details
splash.jsA new module responsible for:
.env.BrowserWindow.index.jsModified the Electron entry point to:
app.whenReady().browser-window-createdevent to dismiss the splash screen once the Laravel app is ready.✅ Checklist
native:serve)native:build).envparsing logic on Windowsfalse)