This package is abandoned and no longer maintained. No replacement package was suggested.

native readline implementation forked from ridzhi/readline

v0.2.0 2017-03-28 09:15 UTC

This package is auto-updated.

Last update: 2020-05-09 11:15:20 UTC


native readline implementation



composer require ridzhi/readline



  • Arrow left/right - move cursor left/right
  • Home - move cursor to begin
  • End - move cursor to end
  • Ctrl+Delete - clear line
  • Page up/down - navigate by history
  • Tab - complete


  • Arrow up/down - scroll up/down
  • Enter - select
  • Esc - remove focus/move to line context


For autocompletion implement CompleteInterface. Also you can use Parser helper, which return Info object. Info has API for writting completers practically any complexity. For more details see example dir.

use \Ridzhi\Readline\Info\InfoInterface as IInfo;

class TestCompleter implements \Ridzhi\Readline\CompleteInterface

    public function complete(string $input): array
        $info = \Ridzhi\Readline\Info\Parser::parse($input);

        switch ($info->getType()) {
            case IInfo::TYPE_ARG:
                // arg completion
            case IInfo::TYPE_OPTION_SHORT:
                // option completion
            case IInfo::TYPE_OPTION_LONG:
                // option completion
            case IInfo::TYPE_OPTION_VALUE:
                // option values completion
                return [];



For most popular frameworks (Yii2, Symfony, Laravel) completers will be written at soon.

Custom handlers

Remove line from current cursor position to end.

$readline = new \Ridzhi\Readline\Readline();
$readline->bind("\033d", function (\Ridzhi\Readline\Line $line) {
    $current = $line->getCurrent();

Close open parenthesis.

$readline = new \Ridzhi\Readline\Readline();

$readline->bind("(", function (\Ridzhi\Readline\Line $line) {


For custom stylish use ThemeInterface implementation.

// dark theme file

class DarkTheme implements Ridzhi\Readline\Dropdown\ThemeInterface

// console app file

// ThemeInterface implements
$readline = new \Ridzhi\Readline\Readline(new DarkTheme());

Also you can use CustomTheme class, it has ready setters API for you design.