PHPackages                             winbox/args - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. winbox/args

ActiveLibrary[CLI &amp; Console](/categories/cli)

winbox/args
===========

Windows command-line formatter

v1.1.1(6y ago)21714.4k—5%420MITPHPPHP ^5.3.2 || ^7.0 || ^8.0

Since Aug 4Pushed 6y ago2 watchersCompare

[ Source](https://github.com/johnstevenson/winbox-args)[ Packagist](https://packagist.org/packages/winbox/args)[ Docs](http://github.com/johnstevenson/winbox-args)[ RSS](/packages/winbox-args/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (20)

Winbox-Args
===========

[](#winbox-args)

[![Build Status](https://camo.githubusercontent.com/cf85dad61952fd462fb36497838476a4bc002043fee3fbd8de3a502e2a81db48/68747470733a2f2f7472617669732d63692e6f72672f6a6f686e73746576656e736f6e2f77696e626f782d617267732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/johnstevenson/winbox-args)[![Build status](https://camo.githubusercontent.com/bcf860a5999aaf8e8556ae0cef009a5a441970edb8b45688e7df7e9f826c4fa1/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f70346b373571716379696f6a306d666c3f7376673d74727565)](https://ci.appveyor.com/project/johnstevenson/winbox-args)

A PHP function to escape command-line arguments, which replaces `escapeshellarg` with more robust methods for both Windows and non-Windows platforms. Install from [Packagist](https://packagist.org/packages/winbox/args) and use it like this:

```
$escaped = Winbox\Args::escape($argument);
```

Alternatively, you can just [copy the code](https://github.com/johnstevenson/winbox-args/blob/master/src/Args.php#L15) into your own project (but please keep the license attribution and documentation link).

### What it does on the Windows platform

[](#what-it-does-on-the-windows-platform)

The following transformations are made:

- Double-quotes are escaped with a backslash, with any preceeding backslashes doubled up.
- The argument is only enclosed in double-quotes if it contains whitespace or is empty.
- Trailing backslashes are doubled up if the argument is enclosed in double-quotes.

See [How Windows parses the command-line](https://github.com/johnstevenson/winbox-args/wiki/How-Windows-parses-the-command-line) if you would like to know why.

By default, *cmd.exe* meta characters are also escaped:

- by caret-escaping the transformed argument (if it contains internal double-quotes or `%...%` syntax).
- or by enclosing the argument in double-quotes.

There are some limitations:

1. If *cmd* is started with *DelayedExpansion* enabled, `!...!` syntax could expand environment variables.
2. If the program name requires caret-escaping and contains whitespace, *cmd* will not recognize it.
3. If an argument contain a newline `\n` character, this will not be escaped.

See [How cmd.exe parses a command](https://github.com/johnstevenson/winbox-args/wiki/How-cmd.exe-parses-a-command) and [Implementing a solution](https://github.com/johnstevenson/winbox-args/wiki/Implementing-a-solution) for more information.

### What it does on non-Windows platforms

[](#what-it-does-on-non-windows-platforms)

The argument is enclosed is single-quotes, with internal single-quotes escaped.

### Is that it?

[](#is-that-it)

Yup. An entire repo for a tiny function. However, it needs quite a lot of explanation because:

- the command-line parsing rules in Windows are not immediately obvious.
- PHP generally uses *cmd.exe* to execute programs and this applies a different set of rules.
- there is no simple solution.

Full details explaining the different parsing rules, potential pitfalls and limitations can be found in the [Wiki](https://github.com/johnstevenson/winbox-args/wiki/Home).

License
-------

[](#license)

Winbox-Args is licensed under the MIT License - see the LICENSE file for details.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~595 days

Total

3

Last Release

2384d ago

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.3

v1.1.0PHP ^5.3.2 || ^7.0

v1.1.1PHP ^5.3.2 || ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/27d8b7d4cfabb5ee43654da874119af04150f7a3da33bd70f66cc311a0bea8cf?d=identicon)[johnstevenson](/maintainers/johnstevenson)

---

Top Contributors

[![johnstevenson](https://avatars.githubusercontent.com/u/881777?v=4)](https://github.com/johnstevenson "johnstevenson (45 commits)")

---

Tags

commandwindowsEscape

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/winbox-args/health.svg)

```
[![Health](https://phpackages.com/badges/winbox-args/health.svg)](https://phpackages.com/packages/winbox-args)
```

###  Alternatives

[league/climate

PHP's best friend for the terminal. CLImate allows you to easily output colored text, special formats, and more.

1.9k14.0M273](/packages/league-climate)[league/tactician

A small, flexible command bus. Handy for building service layers.

86415.4M127](/packages/league-tactician)[nategood/commando

PHP CLI Commando Style

8123.3M38](/packages/nategood-commando)[helhum/typo3-console

A reliable and powerful command line interface for TYPO3 CMS

2939.0M192](/packages/helhum-typo3-console)[jmose/command-scheduler-bundle

This Symfony bundle will allow you to schedule all your commands just like UNIX crontab

3361.4M1](/packages/jmose-command-scheduler-bundle)[adhocore/cli

Command line interface library for PHP

3501.2M50](/packages/adhocore-cli)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
