Skip to content

Commit 9bc9072

Browse files
committed
add ChildProcess::node() to docs
1 parent 1c3b893 commit 9bc9072

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

resources/views/docs/desktop/2/digging-deeper/child-processes.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ NativePHP provides a similar method convenience for Artisan commands:
147147
ChildProcess::artisan('smtp:serve', alias: 'smtp-server');
148148
```
149149

150+
### Node scripts
151+
152+
NativePHP provides a convenient method to execute JavaScript files using the bundled Node.js runtime:
153+
154+
```php
155+
ChildProcess::node(
156+
cmd: 'resources/js/websocket-server.js',
157+
alias: 'websocket-server'
158+
);
159+
```
160+
161+
This method automatically uses the Node.js runtime that ships with your NativePHP application, ensuring consistency across different environments.
162+
163+
**Key benefits:**
164+
- No need to compile JavaScript files beforehand
165+
- Dependencies can be used directly without bundling for browser compatibility
166+
- Leverages the same Node.js version across all platforms
167+
150168
## Getting running processes
151169

152170
### Getting a single process

0 commit comments

Comments
 (0)