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

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

programster/cli-menu
====================

Cli Menu code for writing CLI applications in PHP 5.3+

2.1.2(4y ago)0104[1 issues](https://github.com/programster/package-cli-menu/issues)nonePHPPHP &gt;=8.0.0

Since Nov 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/programster/package-cli-menu)[ Packagist](https://packagist.org/packages/programster/cli-menu)[ Docs](http://blog.programster.org/)[ RSS](/packages/programster-cli-menu/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (7)Used By (0)

CLI Menu
========

[](#cli-menu)

This package makes it simple to create menus in the CLI for terminal applications. There are two primary types.

- Action Menu - print out a list of options and the options fire a callback that does something. E.g. exit the program or process a file.
- Value Menu - prompt the user to make a choice from a limited set. E.g. output a list of the local files, and have the user select one by typing in the menu option index instead of a full path.

Install
-------

[](#install)

Install the package with:

```
composer require programster/cli-menu
```

Example Code
------------

[](#example-code)

### Action Menu

[](#action-menu)

Here is some code demonstrating that you can build an action menu out of simple clusures, or even invokable objects:

```
$overComplicatedPrintHelloWorldObject = new class {
    public function __invoke() {
        print PHP_EOL . "Hello world!" . PHP_EOL;
    }
};

$exitCallback = function() { die("Goodbye then!" . PHP_EOL); };
$sayHelloWorldOption = new \Programster\CliMenu\MenuOption("Print hello world", $overComplicatedPrintHelloWorldObject);
$exitOption = new \Programster\CliMenu\MenuOption("Exit", $exitCallback);
$cliMenu = new Programster\CliMenu\ActionMenu("My Action Menu", $sayHelloWorldOption, $exitOption);

while(true)
{
    $cliMenu->run();
}
```

### Value Menu

[](#value-menu)

Here is a basic example where we get the user to pick the number of seconds they wish for:

```
$possibleValues = array(
    new Programster\CliMenu\ValueOption("Seconds in a day", (60 * 60 * 24)),
    new Programster\CliMenu\ValueOption("Seconds in a week", (60 * 60 * 24 * 52)),
    new Programster\CliMenu\ValueOption("Seconds in a year", (60 * 60 * 24 * 365)),
);

$valueMenu = new Programster\CliMenu\ValueMenu("Pick your seconds amount", ...$possibleValues);

$chosenValue = $valueMenu->run();
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~564 days

Total

5

Last Release

1606d ago

Major Versions

1.0.0 → 2.0.02021-07-06

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

2.0.0PHP &gt;=7.4.0

2.1.0PHP &gt;=8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/64a048ca8be761aced9419279975a21ef679b71c70d8263bc2fc413a87ad381c?d=identicon)[programster](/maintainers/programster)

---

Top Contributors

[![programster](https://avatars.githubusercontent.com/u/5709838?v=4)](https://github.com/programster "programster (14 commits)")[![iRAP-Stu](https://avatars.githubusercontent.com/u/115175332?v=4)](https://github.com/iRAP-Stu "iRAP-Stu (1 commits)")

---

Tags

librarycore

### Embed Badge

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

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

###  Alternatives

[ollyxar/php-malware-detector

PHP malware detector

13027.1k](/packages/ollyxar-php-malware-detector)[toolkit/cli-utils

useful cli tool library of the php

20230.2k17](/packages/toolkit-cli-utils)[eddiriarte/console-select

A fancy selection interface for symfony's console component.

127.2k2](/packages/eddiriarte-console-select)[jobmetric/laravel-package-core

It is a standard package of different components of Laravel that helps you write different packages better and more fluently

112.4k43](/packages/jobmetric-laravel-package-core)

PHPackages © 2026

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