PHP Coreutils aims to provide a familiar set of Unix-like tools implemented
entirely in PHP, without relying on shell execution (exec, shell_exec,
etc.). The goal is simplicity, portability, and usability in environments where
shell access is limited or unavailable.
This project is inspired by the philosophy of traditional Unix utilities:
- Do one thing well
- Keep interfaces simple
- Allow composition of small tools
In many environments—such as shared hosting or web-based file managers—access to system-level utilities is restricted. PHP Coreutils fills that gap by offering a minimal, self-contained toolkit for file and text manipulation using pure PHP.
- Pure PHP implementation (no external dependencies required)
- Unix-like command semantics
- Designed for portability across environments
- Safe for restricted or sandboxed execution contexts
$data = cat("file.txt");
$data = grep("ERROR", $data);
$count = wc($data);This project does not attempt to fully replicate a Unix shell. Instead, it provides function-based equivalents of common utilities, allowing developers to compose operations programmatically.
Pipelines are represented through function composition rather than shell pipes:
$count = wc(
grep("ERROR",
cat("file.txt")
)
);The project focuses on core utilities such as:
- File operations (
ls,cp,mv,rm, etc.) - Text processing (
cat,grep,head,tail,wc, etc.) - Shell built-in (
echo,cd,print,pwd, etc.)
The goal is not to achieve full parity with system implementations, but to provide practical and predictable behavior.
Clone the repository:
git clone https://github.com/nerun/php-coreutils.gitInclude it in your project as needed.
Functions are designed to be simple and composable. Each function:
- Accepts standard PHP data types (e.g., strings or arrays)
- Returns data suitable for further processing
Refer to the source code for available functions and usage patterns.
- Not a replacement for a real shell environment
- May load entire files into memory depending on implementation
- Behavior may differ from native Unix utilities in edge cases
Contributions are welcome. Keep changes:
- Small
- Focused
- Consistent with the project philosophy