mcuadros/cli-array-editor

此包已被弃用,不再维护。未建议替代包。

此库提供了一种在CLI中使用vim或您喜欢的编辑器轻松编辑数组的方法。

dev-master 2013-04-08 10:02 UTC

This package is not auto-updated.

Last update: 2020-06-12 17:39:53 UTC


README

此库提供了一种在CLI中使用vim或您喜欢的编辑器轻松编辑数组的方法。

在需要从CLI PHP应用程序界面编辑数组的情况下非常有用。CLIArrayEditor将以可读格式(json、yaml等)打开编辑器并等待用户(如"crontab -e"或"git commit")。

编辑器可以通过配置或默认使用环境中的$EDITOR。

需求

  • PHP 5.3.23;
  • Unix系统;
  • PECL yaml >= 0.5.0(可选)

安装

安装CLIArrayEditor的推荐方法是通过composer。您可以在Packagist上查看包信息

{
    "require": {
        "mcuadros/cli-array-editor": "dev"
    }
}

示例

use CLIArrayEditor\Editor;
use CLIArrayEditor\Format\JSON;

$tmp = array(
    'baz' => true,
    'foo' => 'bar'
);

$editor = new Editor();
$result = $editor
    ->setFormat(new JSON)
    ->edit($tmp);

print_r($result);

src/CLIArrayEditor/Editor.php中检查可用的编辑器方法

测试

测试在tests文件夹中。要运行它们,您需要PHPUnit。示例

$ phpunit --configuration phpunit.xml.dist

许可证

MIT,请参阅LICENSE