diff --git a/src/utils/execPHP.ts b/src/utils/execPHP.ts index 15b13f8..dd9d1e2 100644 --- a/src/utils/execPHP.ts +++ b/src/utils/execPHP.ts @@ -5,6 +5,7 @@ */ import { PHP_ERROR, PHP_TEMPLATE } from '../public' +import { dirname } from 'path' import { exec } from 'child_process' import fs from 'fs' @@ -52,7 +53,7 @@ export class ExecPHP { const cmd = `"${this.php}" "${absolutePath}"` // https://nodejs.org/docs/latest-v18.x/api/child_process.html#child_processexeccommand-options-callback - exec(cmd, { maxBuffer: 1024 * 1024 * 2 }, function (error, stdout, stderr) { + exec(cmd, { maxBuffer: 1024 * 1024 * 2, cwd: dirname(absolutePath) }, function (error, stdout, stderr) { if (error) returnWithError(`

error: ${error.message}

`, PHP_ERROR) if (stderr) returnWithError(`

stderr: ${stderr}

`, PHP_ERROR)