2017 © Pedro Peláez
 

library shell

Interactive shell (cli) component for PHP

image

fieg/shell

Interactive shell (cli) component for PHP

  • Sunday, May 17, 2015
  • by fieg
  • Repository
  • 0 Watchers
  • 2 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Interactive shell (cli) component for PHP, (*1)

Build Status, (*2)

Getting started

use Fieg\Shell\Shell;
use Fieg\Shell\ShellEvents;

$shell = new Shell();

// handle some commands
$shell->on(ShellEvents::COMMAND, function ($command) use ($shell) {
    switch ($command) {
        case "help":
            $shell->publish('Available commands:');
            $shell->publish('  help   Print this help');
            $shell->publish('  exit   Exit program');
            break;

        case "exit":
            $shell->stop();
            break;

        // echo everything else the user types
        default:
            $shell->publish('echo: ' . $command);
    }
});

// print some info
$shell->publish("This is an interactive shell.");
$shell->publish("Type 'help' for all available commands.");

// start a prompt so we can receive user input
$shell->prompt();

// statements after this are only executed when `$shell->stop()` is called
$shell->run();

echo "Bye!" . PHP_EOL;

This library also comes with a history support. With this you can use the up and down arrows to browse through the recently typed commands. To enable the history support, just wrap the Shell class in a HistoryDecorator:, (*3)

$shell = new HistoryDecorator(new Shell());

You can also type the command "history" to see a list of all recently typed commands., (*4)

The Versions

17/05 2015

dev-master

9999999-dev

Interactive shell (cli) component for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

cli shell interactive

17/05 2015

1.0

1.0.0.0

Interactive shell (cli) component for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

cli shell interactive