承接 net_bazzline/php_component_cli_readline 相关项目开发

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

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

net_bazzline/php_component_cli_readline

最新稳定版本:1.2.2

Composer 安装命令:

composer require net_bazzline/php_component_cli_readline

包简介

free as in freedom php component to easy up usage of php readline implementation in php 5.3 and above

README 文档

README

I still like the idea but there is currently no use case to develop it anymore.

Readline Component for PHP

This project aims to deliver an easy to use and free as in freedom php compontent for dealing with unix console readline and autocomplete php scripts.

The build status of the current master branch is tracked by Travis CI: Build Status Latest stable

The scrutinizer status are: code quality | build status

The versioneye status is: Dependency Status

Take a look on openhub.net.

The current change log can be found here.

Benefits

  • autocomplete support
  • readline support
  • configuration as array
    • set array with possible autocomplete options
    • bind actions to specific autocomplete options
    • supports function, closures and objects as autocomplete target
  • easy up php's readline implementation as seen here
  • works with PHP 5.3 and above

Usage

use Net\Bazzline\Component\Cli\Readline\ManagerFactory;

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

$factory    = new ManagerFactory();
$manager    = $factory->create();
$myClass    = new MyClass();    //assuming a class "MyClass" exists

$manager->setConfiguration(
    array(
        'git' => array(
            'add' => function ($files) {
                if (!is_null($files)) {
                    passthru('/usr/bin/env git add ' . implode(' ', $files));
                }
            },
            'commit' => function ($message) {
                if (is_null($message)) {
                    passthru('/usr/bin/env git commit');
                } else {
                    passthru('/usr/bin/env git commit -m "' . (string) $message . '"');
                }
            }
        ),
        'info' => 'phpinfo',
        'my' => array(
            'function_one' => array($myClass, 'one'),   //assuming MyClass has a method "one"
            'function_two' => array($myClass, 'two')    //assuming MyClass has a method "two"
        )
    )
);
$manager->setPrompt(': ');
$manager->run();

The example above would result into the following possible autocompletion cases.

  • no word
    • git
    • info
    • my
  • first word is git
    • add
    • commit
  • first word is my
    • function_one
    • function_two

Install

By Hand

mkdir -p vendor/net_bazzline/php_component_cli_readline
cd vendor/net_bazzline/php_component_cli_readline
git clone https://github.com/bazzline/php_component_cli_readline .

With Packagist

composer require net_bazzline/php_component_cli_readline:dev-master

API

API is available at bazzline.net.

Other Great Components

Final Words

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it :-D.

统计信息

  • 总下载量: 1.33k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-07-06