Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/php-wasm/cli/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dev": {
"executor": "nx:run-commands",
"options": {
"command": "bun --watch ./packages/php-wasm/cli/src/main.ts",
"command": "node --no-warnings --experimental-wasm-stack-switching --experimental-wasm-jspi --loader=./packages/meta/src/node-es-module-loader/loader.mts ./packages/php-wasm/cli/src/main.ts",
"tty": true
}
},
Expand Down
14 changes: 14 additions & 0 deletions packages/php-wasm/cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { SupportedPHPVersion } from '@php-wasm/universal';
import { FileLockManagerForNode } from '@php-wasm/node';
import { PHP } from '@php-wasm/universal';
import { loadNodeRuntime, useHostFilesystem } from '@php-wasm/node';
import { startBridge } from '@php-wasm/xdebug-bridge';
import path from 'path';

let args = process.argv.slice(2);
Expand Down Expand Up @@ -43,6 +44,13 @@ async function run() {
args = args.filter((arg) => arg !== '--xdebug');
}

const hasDevtoolsOption = args.some((arg) =>
arg.startsWith('--experimental-devtools')
);
if (hasDevtoolsOption) {
args = args.filter((arg) => arg !== '--experimental-devtools');
}

// npm scripts set the TMPDIR env variable
// PHP accepts a TMPDIR env variable and expects it to
// be a writable directory within the PHP filesystem.
Expand Down Expand Up @@ -97,6 +105,12 @@ ${process.argv[0]} ${process.execArgv.join(' ')} ${process.argv[1]}

useHostFilesystem(php);

if (hasDevtoolsOption && hasXdebugOption) {
const bridge = await startBridge({});

bridge.start();
}

const hasMinusCOption = args.some((arg) => arg.startsWith('-c'));
if (!hasMinusCOption) {
args.unshift('-c', defaultPhpIniPath);
Expand Down
4 changes: 4 additions & 0 deletions packages/php-wasm/cli/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ export default defineConfig({
external: [
'@php-wasm/node',
'@php-wasm/universal',
'assert',
'net',
'fs',
'path',
'child_process',
'http',
'stream',
'timers',
'tls',
'url',
'util',
'dns',
'ws',
Expand Down
Loading