https://github.com/mcuadros/cli-array-editor
This class provides an easy way to edit arrays in CLI using vim or your preferred editor.
https://github.com/mcuadros/cli-array-editor
Last synced: 2 months ago
JSON representation
This class provides an easy way to edit arrays in CLI using vim or your preferred editor.
- Host: GitHub
- URL: https://github.com/mcuadros/cli-array-editor
- Owner: mcuadros
- License: mit
- Archived: true
- Created: 2013-04-05T11:10:46.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-04-08T10:02:13.000Z (over 12 years ago)
- Last Synced: 2025-01-18T15:54:04.036Z (11 months ago)
- Language: PHP
- Homepage:
- Size: 148 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
CLIArrayEditor [](https://travis-ci.org/mcuadros/cli-array-editor)
==============================
This library provides an easy way to edit arrays in CLI using vim or your preferred editor.
Can be useful in scenarios where we need an interface to edit arrays from a CLI PHP application, CLIArrayEditor will open an editor with the array in a readable format (json, yaml, etc) and wait for the user (like "crontab -e" or "git commit").
The editor can be configured or by default $EDITOR from the environment will be used.
Requirements
------------
* PHP 5.3.23;
* Unix system;
* PECL yaml >= 0.5.0 (optional)
Installation
------------
The recommended way to install CLIArrayEditor is [through composer](http://getcomposer.org).
You can see [package information on Packagist.](https://packagist.org/packages/mcuadros/cli-array-editor)
```JSON
{
"require": {
"mcuadros/cli-array-editor": "dev"
}
}
```
Examples
--------
```php
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);
```
Check available Editor's methods in [src/CLIArrayEditor/Editor.php](src/CLIArrayEditor/Editor.php)
Tests
-----
Tests are in the `tests` folder.
To run them, you need PHPUnit.
Example:
$ phpunit --configuration phpunit.xml.dist
License
-------
MIT, see [LICENSE](LICENSE)