Skip to content

fix(php): resolve path import error and ensure ESM compatibility #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mohsenfathipour
Copy link

Fixes the PHP binary extraction errors reported in #336 by:

  • Properly handling ESM path resolution
  • Adding missing environment variable validation
  • Ensuring cross-platform compatibility

Changes:
ESM Path Fixes

  • Added proper imports for resolve and dirname from path
  • Replaced import.meta.dirname with fileURLToPath (ESM standard)
  • Fixed join() operations that could receive undefined values

Error Prevention

  • Added validation for NATIVEPHP_PHP_BINARY_PATH
  • Added validation for NATIVEPHP_PHP_BINARY_VERSION
  • Clear error messages for missing requirements

Tested Environments

Platform Arch Status
macOS x86 ✔️
macOS ARM64 ✔️
Windows x64 ✔️
Linux x64 ✔️

Impact:

  • Resolves PHP binary deployment failures in production builds
  • Prevents silent failures when env vars are missing
  • Maintains compatibility with Electron's ESM requirements

Verification Steps

  1. Configure environment:
    export NATIVEPHP_PHP_BINARY_PATH="/path/to/php/binaries"
    export NATIVEPHP_PHP_BINARY_VERSION="8.3"
  2. Test execution:
    node resources/js/php.js
  3. Confirm:
    • PHP binary exists at resources/php/php[.exe]
    • Correct permissions set (755/executable)

Closes #336

@PeteBishwhip PeteBishwhip requested a review from a team May 9, 2025 08:16
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.

1 participant