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

ActiveLibrary

simple-cli/simple-cli
=====================

A simple command line framework

2.0.0(4y ago)11552.5k↑10.3%2[2 PRs](https://github.com/kylekatarnls/simple-cli/pulls)5MITPHPPHP ^8.0

Since Jul 7Pushed 3y agoCompare

[ Source](https://github.com/kylekatarnls/simple-cli)[ Packagist](https://packagist.org/packages/simple-cli/simple-cli)[ Fund](https://tidelift.com/funding/github/packagist/simple-cli/simple-cli)[ RSS](/packages/simple-cli-simple-cli/feed)WikiDiscussions master Synced 1mo ago

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

simple-cli
==========

[](#simple-cli)

[![Latest stable version](https://camo.githubusercontent.com/3dcd36a04e7c5cb4b21521099c83f4aca1e072ba149c89f78687788992c74646/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696d706c652d636c692f73696d706c652d636c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/simple-cli/simple-cli)[![GitHub Actions](https://camo.githubusercontent.com/f6b27d88d2754729813ff465ee9d29b10a53684a796b32b0a2c86784eb5a5030/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e742e7376673f75726c3d6874747073253341253246253246616374696f6e732d62616467652e6174726f782e6465762532466b796c656b617461726e6c7325324673696d706c652d636c692532466261646765267374796c653d666c61742d737175617265266c6162656c3d4275696c64266c6f676f3d6e6f6e65)](https://actions-badge.atrox.dev/kylekatarnls/simple-cli/goto)[![StyleCI](https://camo.githubusercontent.com/2c6c386f24a08b01c4930991c1bf623ca69449fd40af49650968cd73c63be7ef/68747470733a2f2f7374796c6563692e696f2f7265706f732f3139323137363931352f736869656c643f7374796c653d666c61742d737175617265)](https://styleci.io/repos/192176915)[![codecov.io](https://camo.githubusercontent.com/49b4322af9e6c37cd3ef44e9ce247f3bed12a18c7339e9e822dd44d358a33d28/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6b796c656b617461726e6c732f73696d706c652d636c692e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/kylekatarnls/simple-cli?branch=master)[![PHPStan](https://camo.githubusercontent.com/31ad7b4f47dbce7e8cf0f7ba16b958bffbf22a1b2fabd2e901e37cd2302be626/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)](https://github.com/simple-cli/simple-cli)[![Codacy grade](https://camo.githubusercontent.com/6e3926ace42a9c64dc31fbbd401bcf6a0a54946f97ec6b1f2f52bad0c92f5620/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f30613132396666373461636134373962613231613136643861333136646530373f7374796c653d666c61742d737175617265)](https://app.codacy.com/project/kylekatarnls/simple-cli/dashboard)

A simple CLI framework oriented object and dependencies-free.

[![Example](https://raw.githubusercontent.com/kylekatarnls/simple-cli/master/doc/img/example.jpg)](https://raw.githubusercontent.com/kylekatarnls/simple-cli/master/doc/img/example.jpg)

Features:

- Auto-documentation. `--help` is auto-generated using available commands, arguments and options.
- Clean syntax using PHP 8 attributes.
- Detection of probable mistype and auto-suggestion.
- Based on documentation annotations to preserve ultra-clean code.
- Supports colors.
- Supports interactive commands and auto-completion for CLI input.
- Provides predefined commands: `usage` and `version`.
- Provides predefined options: `--help`, `--quiet` and `--verbose`.
- Provides a CLI to create programs and commands bootstraps.
- Build your program as a PHAR file.

The documentation below is for simple-cli 2 which requires PHP 8 and supports both attributes and annotations.

[simple-cli 1](https://github.com/kylekatarnls/simple-cli/tree/1.x#readme)is compatible with PHP &gt;= 7.1 and supports only annotations.

Create a command line program
-----------------------------

[](#create-a-command-line-program)

You can add your command line program in any existing composer app, or create a new one using `composer init`.

Then add simple-cli:

```
composer require simple-cli/simple-cli
```

Let say your app allows to add or multiply 2 arguments and you want to call `easy-calc` in your CLI, so you need to create an `EasyCalc` class that extends `SimpleCli\SimpleCli`.

So first check you have a PSR autoload set in your **composer.json**:

```
"autoload": {
    "psr-4": {
        "MyVendorName\\": "src/MyVendorName/"
    }
},
```

(You may need to run `composer update` or `composer dump-autoload` to get the autoload in effect.)

Then create the class so it can be autoloaded, so with the example above, we can create the file `src/MyVendorName/CliApp/EasyCalc.php`:

```
