承接 fieg/shell 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fieg/shell

最新稳定版本:1.0

Composer 安装命令:

composer require fieg/shell

包简介

Interactive shell (cli) component for PHP

README 文档

README

Interactive shell (cli) component for PHP

Build Status

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:

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

You can also type the command "history" to see a list of all recently typed commands.

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-17