Skip to content

Commit 0a2155d

Browse files
committed
Fix php.exe loading on Windows
1 parent 161303e commit 0a2155d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

resources/js/php.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ if (phpBinaryPath) {
5757
zipfile.openReadStream(entry, function (err, readStream) {
5858
if (err) throw err;
5959

60-
const writeStream = fs.createWriteStream(join(binaryDestDir, 'php'));
60+
const binaryPath = join(binaryDestDir, phpBinaryFilename);
61+
const writeStream = fs.createWriteStream(binaryPath);
6162

6263
readStream.pipe(writeStream);
6364

6465
writeStream.on("close", function() {
65-
console.log('Copied PHP binary to ', binaryDestDir);
66+
console.log('Copied PHP binary to ', binaryPath);
6667

6768
// Add execute permissions
68-
fs.chmod(join(binaryDestDir, 'php'), 0o755, (err) => {
69+
fs.chmod(binaryPath, 0o755, (err) => {
6970
if (err) {
7071
console.log(`Error setting permissions: ${err}`);
7172
}

resources/js/src/main/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import {app} from 'electron'
22
import NativePHP from '@nativephp/electron-plugin'
3+
import path from 'path'
34
import defaultIcon from '../../resources/icon.png?asset&asarUnpack'
4-
// We can use `php` on all platforms because on Windows we copy the php.exe to `php` in electron-builder.js
5-
import phpBinary from '../../resources/php/php?asset&asarUnpack'
65
import certificate from '../../resources/cacert.pem?asset&asarUnpack'
76

7+
const isWin = process.platform === 'win32';
8+
9+
const phpBinary = path.join(__dirname, '../../resources', isWin ? 'php/php.exe' : 'php/php');
10+
811
/**
912
* Turn on the lights for the NativePHP app.
1013
*/

0 commit comments

Comments
 (0)