Nette Utils 4.1.4 introduces the `Nette\Utils\Process` class as a safe, ergonomic alternative to PHP's `proc_open()` and `shell_exec()`. It provides two execution modes: `runExecutable()` for shell-injection-safe argument passing, and `runCommand()` for full shell features. The class supports real-time output streaming via callbacks, separate stdout/stderr capture, writing output directly to files, configurable timeouts with forceful process termination (SIGKILL/taskkill), and piping processes together without a shell. It works consistently across Linux, macOS, and Windows.

4m read timeFrom blog.nette.org
Post cover image
Table of contents
How to Execute a Command and Get the Exit Code in PHPrunExecutable vs. runCommand (Preventing Shell Injection)Streaming and Reading Process Output in Real-TimeWriting Large Process Output Directly to a FileHow to Set a Timeout for External Processes in PHPPiping Processes Together in PHP (stdin / stdout)

Sort: