EN

Make a command-line app

A JumPHP CLI app is a program that lives in the terminal: commands (todo add "Buy milk") written with Symfony Console, and full-screen text screens (lists, fields, progress bars, keyboard) with symfony/tui. The same project gives one executable for Linux, Windows and macOS.

Create the project

In the JumPHP IDE: New Project, then CLI app. On the command line:

bin/jumphp cli:new todo "Todo"
bin/jumphp install todo

The example is a task list: src/Main.php (the application and its commands), src/Command/ (one class per command), src/Ui/ (the full-screen screens).

Run and test

bin/jumphp run todo                          # the full-screen screen, in this terminal
bin/jumphp run todo add "Buy milk"        # a command
bin/jumphp test todo                         # php -l, phpstan, PHPUnit
bin/jumphp shot todo 2                       # the screen as text: var/screenshots/screen.txt

With no command, the app opens its screen when its output is a terminal, and prints a plain list when it goes to a file or another program: it stays usable in scripts.

Tests play the commands (ApplicationTester) and the screens on a virtual terminal (VirtualTerminal): they type keys and read what the user would see.

Data

The app keeps its data in the user's folder (~/.local/share/<id>, %APPDATA%\<id>, ~/Library/Application Support/<id>), and in var/ while you develop it.

Distribute

bin/jumphp export:standalone todo --linux --windows --macos

One executable per system, nothing to install; on Windows it is a console program. bin/jumphp installer todo also makes installers of it (Windows, Linux).

On Windows the commands work in any console; the full-screen screens need a terminal with stty (WSL, Git Bash).