PHPackages                             phpgt/cli - 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. phpgt/cli

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

phpgt/cli
=========

Command line interface builder.

v1.3.5(2y ago)09.3k↓15%[3 PRs](https://github.com/PhpGt/Cli/pulls)8MITPHPPHP &gt;=8.2CI passing

Since Apr 1Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/PhpGt/Cli)[ Packagist](https://packagist.org/packages/phpgt/cli)[ GitHub Sponsors](https://github.com/sponsors/PhpGt)[ RSS](/packages/phpgt-cli/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (35)Used By (8)

Command line interface builder.
===============================

[](#command-line-interface-builder)

Create multi-command terminal application with parameter requirements that are self-documenting and easy to unit test.

---

[ ![Build status](https://camo.githubusercontent.com/84f89a9b3b4b1fac79903c3b870b4e64a7d4a301d0d4da09b0b70e1f8d5a92ac/68747470733a2f2f62616467652e7374617475732e7068702e67742f636c692d6275696c642e737667)](https://github.com/PhpGt/Cli/actions)[ ![Code quality](https://camo.githubusercontent.com/c11007c50fcf44b0dfd6898b0e2ada48ed64eff0baefab8e9c73ec80882d2340/68747470733a2f2f62616467652e7374617475732e7068702e67742f636c692d7175616c6974792e737667)](https://app.codacy.com/gh/PhpGt/Cli)[ ![Code coverage](https://camo.githubusercontent.com/18389a2181c5e70ca1ded278abec53b423ff80d0967b781dbe54a5ec796cf80d/68747470733a2f2f62616467652e7374617475732e7068702e67742f636c692d636f7665726167652e737667)](https://app.codecov.io/gh/PhpGt/Cli)[ ![Current version](https://camo.githubusercontent.com/99b446a4908ed6fc27cb7dd44fd81b7b83e14678b8a2ff06f69eede18c71d309/68747470733a2f2f62616467652e7374617475732e7068702e67742f636c692d76657273696f6e2e737667)](https://packagist.org/packages/PhpGt/Cli)[ ![PHP.G/Cli documentation](https://camo.githubusercontent.com/a4a5fd42038690f971a9636e42e1f8036a14c231f4d8be3e58b24ac1ae1c5a2c/68747470733a2f2f62616467652e7374617475732e7068702e67742f636c692d646f63732e737667)](https://www.php.gt/cli)Example usage: Twitter client
-----------------------------

[](#example-usage-twitter-client)

CLI interaction:

```
$ twitter tweet --message "Sending a test Tweet from the terminal."
Sent! View online: https://twitter.com/g105b/status/1038509073346510849
$ twitter dm --to @g105b --message "Hello, Greg!"
Sent!
$ twitter help
Twitter example application

Available commands:
• tweet		Send a Tweet to your timeline.
• view		View your timeline
• follow	Follow an account
• dm		Send a direct message.
• login		Authenticate your username.
• help		Show this help screen.
```

`twitter.php:`

```
$app = new Application(
	"Twitter example application",
	new CliArgumentList(...$argv),
	new TweetCommand(),
	new ViewCommand(),
	new FollowCommand(),
	new DmCommand(),
	new LoginCommand()
);
$app->run();
```

`Command/tweet.php`

```
class TweetCommand extends Command {
	public function __construct() {
		$this->setName("tweet");
		$this->setDescription("Send a Tweet to your timeline.");

		$this->setRequiredParameter(true, "message", "m");
		$this->setOptionalParameter(true, "location", "l");
	}

	public function run(?ArgumentValueList $arguments = null):int {
		if(!TwitterApi::isLoggedIn()) {
			$this->writeLine("You must login first.", Stream::ERROR);
			return 1;
		}

		try {
			$uri = TwitterApi::sendTweet($arguments->get("message"));
			$this->writeLine("Sent! View online: $uri");
		}
			catch(TwitterApiException $exception) {
				$this->writeLine(
					"Error sending Tweet: "
					. $exception->getMessage(),
					Stream::ERROR
				);
				return 2;
			}

			return 0;
	}
}
```

Coloured output
---------------

[](#coloured-output)

Within a `Command`, output can be coloured consistently using the palette API:

```
$this->output("some text", Palette::GREEN); // single green message, resets afterwards
$this->setOutputPalette(Palette::RED, Palette::BLACK); // set default fg/bg
$this->output("all output now uses the default palette");
$this->resetOutputPalette(); // reset to terminal default
```

Proudly sponsored by
====================

[](#proudly-sponsored-by)

[JetBrains Open Source sponsorship program](https://www.jetbrains.com/community/opensource/)

[![JetBrains logo.](https://camo.githubusercontent.com/b5639e7738c6dfae9fe3f3e20175570b7376ce2577a772e09c25c2d4f14bf86e/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a6574627261696e732e737667)](https://www.jetbrains.com/community/opensource/)

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance59

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50% 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 ~93 days

Recently: every ~294 days

Total

25

Last Release

740d ago

Major Versions

v0.3.3 → v1.0.02019-01-17

PHP version history (4 changes)v1.1.2PHP &gt;=7.2

v1.3.0PHP &gt;=7.4

v1.3.2PHP &gt;=8.0

v1.3.5PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e42344b91ce4b91ab57875969f67a0a6a48de570a08bc65d673b06b72fd3a3f?d=identicon)[g105b](/maintainers/g105b)

---

Top Contributors

[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (24 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (12 commits)")[![g105b](https://avatars.githubusercontent.com/u/358014?v=4)](https://github.com/g105b "g105b (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

clicli-apicli-appcli-applicationcli-frameworkcommand-line-interface-builderphpgtterminalterminal-colorscliterminalwebenginephpgt

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpgt-cli/health.svg)

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

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[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)[php-school/cli-menu

A command line menu helper in PHP

2.0k1.1M27](/packages/php-school-cli-menu)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[aplus/cli

Aplus Framework CLI Library

2301.7M6](/packages/aplus-cli)[splitbrain/php-cli

Easy command line scripts for PHP with opt parsing and color output. No dependencies

177817.2k28](/packages/splitbrain-php-cli)

PHPackages © 2026

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