writeln("Executing command"); } } class MyShell extends Shell { protected $seq = 0; protected function configure(array $config) { $this->addCommand("hello", function () { echo "world\n\rthis\n\ris\n\ra\ntest\n\r"; }); $this->addCommand(new MyCommand()); $this->updatePrompt(); } protected function updatePrompt() { $this->setPrompt("test[{$this->seq}]: "); $fg = ($this->seq % 7) + 1; $this->setPromptStyle("3{$fg}"); } protected function onUpdate() { static $lt; $t = floor(microtime(true)); if ($t > $lt) { $lt = $t + 5; echo date("Y-m-d h:i:s")."\n"; } } protected function onCommand($buffer) { $this->seq++; $this->updatePrompt(); parent::onCommand($buffer); } } $myShell = new MyShell(); $myShell->run(); echo "Exiting\n";