PHPackages                             pointybeard/shell-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. pointybeard/shell-args

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

pointybeard/shell-args
======================

A simple interface for processing arguments passed on the command line to PHP.

1.0.4(7y ago)0114MITPHPPHP &gt;=5.6.6

Since Mar 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/pointybeard/shellargs)[ Packagist](https://packagist.org/packages/pointybeard/shell-args)[ RSS](/packages/pointybeard-shell-args/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Shell Arguments for PHP CLI
===========================

[](#shell-arguments-for-php-cli)

- Version: v1.0.4
- Date: October 17th 2018
- [Release notes](https://github.com/pointybeard/shellargs/blob/master/CHANGELOG.md)
- [GitHub repository](https://github.com/pointybeard/shellargs)

[![Latest Stable Version](https://camo.githubusercontent.com/5339c6fed6211e202909738dd2627d51967c83240c0c4814b0c475b6a5854252/68747470733a2f2f706f7365722e707567782e6f72672f706f696e747962656172642f7368656c6c2d617267732f762f737461626c65)](https://packagist.org/packages/pointybeard/shell-args) [![Total Downloads](https://camo.githubusercontent.com/25b10c34d9623cfcd7e36604f807cf2438793e8c460fb89e9b0fa86fba310046/68747470733a2f2f706f7365722e707567782e6f72672f706f696e747962656172642f7368656c6c2d617267732f646f776e6c6f616473)](https://packagist.org/packages/pointybeard/shell-args) [![Latest Unstable Version](https://camo.githubusercontent.com/e4a5872918004254d8ed70c7131b37cc5a644a7dbe18ab09e794882b1fdf6a3b/68747470733a2f2f706f7365722e707567782e6f72672f706f696e747962656172642f7368656c6c2d617267732f762f756e737461626c65)](https://packagist.org/packages/pointybeard/shell-args) [![License](https://camo.githubusercontent.com/09ea9af28e5eca9753659198147fc2118eb4a12534fd761ce6bc637254e4fd75/68747470733a2f2f706f7365722e707567782e6f72672f706f696e747962656172642f7368656c6c2d617267732f6c6963656e7365)](https://packagist.org/packages/pointybeard/shell-args)

A convenience class for loading arguments passed through the command line (`$argv`)

- Autoloads from `$argv`, or pass in handcrafted array
- Uses the Iterator base class, but adds `find()` to make looking for, and testing, arguments trivial.
- Support for most common argument formats

Installation
------------

[](#installation)

Shell Arguments for PHP CLI is installed via [Composer](http://getcomposer.org/). To install, use `composer require pointybeard/shell-args` or add `"pointybeard/shell-args": "~1.0"` to your `composer.json` file.

Usage
-----

[](#usage)

Include `pointybeard\ShellArgs\Lib` in your scripts then create an instance of `ArgumentIterator`. It will automatically look for arguments, or you can pass it your own argument string (see below).

### Syntax Supported

[](#syntax-supported)

This library supports the most common argument formats. Specifically `-x`,` --long`, `/x`. It also supports use of `=` or `:` as a delimiter. The following are examples of supported argument syntax:

```
-x
--aa
--database=blah
-d:blah
--d blah
--database-name=blah
/d blah
-u http://www.theproject.com
-y something
-p:\Users\pointybeard\Sites\shellargs\
-p:"\Users\pointybeard\Sites"
-h:local:host
/host=local-host

```

### Examples

[](#examples)

```
