Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Arguments Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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']

Implementation Patterns

  • Config-driven command execution: Use Arguments::parse() to convert stored command templates (e.g., "{{bin}} {{config}} --env={{env}}") into parsed args for proc_open() or Symfony\Component\Process\Process.
  • Interoperability with shell commands: Safely preprocess user input before delegating to external tools—avoids injection risks where escapeshellarg() alone is insufficient for complex inputs.
  • Testing CLI parsers: Use Arguments::parse() in unit tests to validate custom argument-handling logic (e.g., when building your own CLI tool or REPL).
  • DSL parsing: Parse domain-specific strings (e.g., "build --watch --port=8080") into structured input for build/run scripts.
  • Fallback for shell_exec(): Prefer Arguments::parse() + proc_open() over shell interpolation for better control and security.

Gotchas and Tips

  • No active maintenance: Last release was in 2020. Verify compatibility with PHP 8.x—despite being pure PHP, it may not be updated for newer versions (check fork activity or consider symfony/process::parse() as a maintained alternative).
  • Missing edge-case handling: Does not handle unbalanced quotes or escaped quotes in all edge cases—test with malformed input (e.g., '"unterminated') to confirm behavior.
  • Whitespace quirks: Adjacent quotes without spaces ("a""b") may collapse to "ab" depending on shell behavior—confirm expectations match your use case.
  • Not for security-critical parsing alone: Use Arguments::parse() plus escapeshellarg() for untrusted inputs when passing to the shell, or better yet, avoid shells entirely (use proc_open() with argument arrays).
  • Performance: Safe for small-to-medium strings; avoid parsing very large inputs repeatedly (cache parsed results where applicable).
  • No Windows-specific escaping: Relies on Unix-like shell semantics; may misparse Windows-style paths with backslashes (e.g., "C:\Program Files\" should be escaped as "C:\Program Files\\" or use forward slashes).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4