Skip to content

Working with Color Themes

Minicli supports the use of color themes to change the style of command line output. The following built-in themes are currently available:

To set the theme, pass in a configuration array with a theme value when initializing the application. Built-in themes need a leading \ character:

$app = new App([
    'theme' => '\Unicorn'

To use the default built-in theme, do not include the theme configuration setting, or set it to an empty string.

Creating a Custom Theme

User-defined themes can also be created and defined in your project. In this case, set the theme name including its namespace without a leading \:

$app = new App([
    'theme' => 'App\Theme\Blue'

The above setting would use the following example theme:

// File: app/Theme/BlueTheme.php

namespace App\Theme;

use Minicli\Output\Theme\DefaultTheme;
use Minicli\Output\CLIColors;

class BlueTheme extends DefaultTheme
    public function getThemeColors(): array
        return [
            'default'     => [ CLIColors::$FG_BLUE ],
            'alt'         => [ CLIColors::$FG_BLACK, CLIColors::$BG_BLUE ],
            'info'        => [ CLIColors::$FG_WHITE],
            'info_alt'    => [ CLIColors::$FG_WHITE, CLIColors::$BG_BLUE ]

User-defined themes only need to define styles which will override those in the default theme.

Theme screenshots


When in doubt, stick to the default.

Screenshot default Theme


A more colorful theme than the default ¯_(ツ)_/¯

Screenshot unicorn Theme


A color-blind friendly theme contributed by Tom Benevides.

Screenshot dalton Theme


Note: Colors will vary depending on your CLI and system colors.

You can use the following Minicli script to reproduce this output:

#!/usr/bin/env php

if (php_sapi_name() !== 'cli') {

require __DIR__ . '/vendor/autoload.php';

use Minicli\App;
use Minicli\Exception\CommandNotFoundException;

$app = new App([
    'app_path' => __DIR__ . '/app/Command',
    'debug' => true,
    'theme' => '\Unicorn'

$app->registerCommand('test', function () use ($app) {
    $app->getPrinter()->display("Hello World");
    $app->getPrinter()->error("Hello World");
    $app->getPrinter()->info("Hello World");
    $app->getPrinter()->success("Hello World");
    $app->getPrinter()->display("Hello World",true);
    $app->getPrinter()->error("Hello World",true);
    $app->getPrinter()->info("Hello World",true);
    $app->getPrinter()->success("Hello World",true);
    $app->getPrinter()->out("Hello World!\r\n", 'underline');
    $app->getPrinter()->out("Hello World!\r\n", 'dim');
    $app->getPrinter()->out("Hello World!\r\n", 'bold');
    $app->getPrinter()->out("Hello World!\r\n", 'inverted');
    $app->getPrinter()->out("Hello World!\r\n", 'italic');

try {
} catch (CommandNotFoundException $notFoundException) {
    $app->getPrinter()->error("Command Not Found.");
    return 1;
} catch (Exception $exception) {
    if ($app->config->debug) {
        $app->getPrinter()->error("An error occurred:");
    return 1;

return 0;