clue/arguments
clue/arguments is a small PHP utility to parse and handle command-line arguments. It helps normalize argv, split options and values, and access flags and parameters easily—useful for building simple CLI tools without pulling in a full console framework.
clue/arguments is a lightweight utility to parse shell-style command strings into PHP arrays, mimicking how shells split arguments (respecting quotes, escapes, etc.). Start by installing via Composer:
composer require clue/arguments
The primary use case is when you need to reliably parse user-provided CLI-style input (e.g., from config files, web forms, or custom DSLs) intoargv-compatible format—especially where explode(' ', $cmd) fails (e.g., "command --option='value with spaces'"). Minimal setup required:
use Clue\Arguments\Arguments;
$parts = Arguments::parse('php script.php "my file.txt" --flag');
// => ['php', 'script.php', 'my file.txt', '--flag']
Arguments::parse() to convert stored command templates (e.g., "{{bin}} {{config}} --env={{env}}") into parsed args for proc_open() or Symfony\Component\Process\Process.escapeshellarg() alone is insufficient for complex inputs.Arguments::parse() in unit tests to validate custom argument-handling logic (e.g., when building your own CLI tool or REPL)."build --watch --port=8080") into structured input for build/run scripts.shell_exec(): Prefer Arguments::parse() + proc_open() over shell interpolation for better control and security.symfony/process::parse() as a maintained alternative).'"unterminated') to confirm behavior."a""b") may collapse to "ab" depending on shell behavior—confirm expectations match your use case.Arguments::parse() plus escapeshellarg() for untrusted inputs when passing to the shell, or better yet, avoid shells entirely (use proc_open() with argument arrays)."C:\Program Files\" should be escaped as "C:\Program Files\\" or use forward slashes).How can I help you explore Laravel packages today?