Skip to content

feat(live-reload): trigger automatic server restart on environment file changes - #3

Merged
fomadev-admin merged 3 commits into
mainfrom
a
Aug 3, 2026
Merged

feat(live-reload): trigger automatic server restart on environment file changes#3
fomadev-admin merged 3 commits into
mainfrom
a

Conversation

@fordimalanda

Copy link
Copy Markdown
Member

Summary

This PR introduces dynamic .env file detection and hot-restarting capability for the underlying PHP server process.

Because PHP environment variables loaded at startup are cached within the running process memory, updating .env files previously required manual server restarts. This update detects changes to environment configuration files and automatically restarts the PHP server before triggering a client browser refresh.

Key Changes

  • Live Reload Detection (src/liveReload.ts):

    • Added an onEnvFileSaved callback hook to notify subscribers when environment files are edited.
    • Intercepted file save events matching .env* patterns (.env, .env.local, etc.), bypassing regular browser reloads to trigger server-level handling.
  • Server Manager Orchestration (src/serverManager.ts):

    • Subscribed to onEnvFileSaved during LiveReloadServer initialization.
    • Implemented automatic execution of restartServer() followed by a broadcast reload to active WebSocket client connections once the server is back online.
  • Documentation (README.md):

    • Updated feature lists and configuration details highlighting automatic .env reloading.
    • Added changelog entries documenting hot server restart behaviors.

Verification

  • Executed Webpack build (npm run compile) successfully without compilation errors.
  • Verified file change handling for .env files vs. standard frontend assets (.php, .html, .js, etc.).

@fomadev-admin
fomadev-admin merged commit 0767c17 into main Aug 3, 2026
1 check passed
fomadev-admin added a commit that referenced this pull request Aug 3, 2026
@fordimalanda
fordimalanda deleted the a branch August 3, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants