Skip to content

Commit

Permalink
Fix php.exe loading on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Apr 30, 2024
1 parent 161303e commit 0a2155d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions resources/js/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ if (phpBinaryPath) {
zipfile.openReadStream(entry, function (err, readStream) {
if (err) throw err;

const writeStream = fs.createWriteStream(join(binaryDestDir, 'php'));
const binaryPath = join(binaryDestDir, phpBinaryFilename);
const writeStream = fs.createWriteStream(binaryPath);

readStream.pipe(writeStream);

writeStream.on("close", function() {
console.log('Copied PHP binary to ', binaryDestDir);
console.log('Copied PHP binary to ', binaryPath);

// Add execute permissions
fs.chmod(join(binaryDestDir, 'php'), 0o755, (err) => {
fs.chmod(binaryPath, 0o755, (err) => {
if (err) {
console.log(`Error setting permissions: ${err}`);
}
Expand Down
7 changes: 5 additions & 2 deletions resources/js/src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {app} from 'electron'
import NativePHP from '@nativephp/electron-plugin'
import path from 'path'
import defaultIcon from '../../resources/icon.png?asset&asarUnpack'
// We can use `php` on all platforms because on Windows we copy the php.exe to `php` in electron-builder.js
import phpBinary from '../../resources/php/php?asset&asarUnpack'
import certificate from '../../resources/cacert.pem?asset&asarUnpack'

const isWin = process.platform === 'win32';

const phpBinary = path.join(__dirname, '../../resources', isWin ? 'php/php.exe' : 'php/php');

/**
* Turn on the lights for the NativePHP app.
*/
Expand Down

0 comments on commit 0a2155d

Please sign in to comment.