docs(README): add README
This commit is contained in:
32
README.md
Normal file
32
README.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# NIH PHP Command Builder
|
||||||
|
|
||||||
|
Simple command builder inspired by rust's std library.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Nih\CommandBuilder\Command;
|
||||||
|
use Nih\CommandBuilder\Stdio;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
$child = (new Command('/usr/bin/cat'))
|
||||||
|
->stdin(Stdio::piped('r'))
|
||||||
|
->spawn(shell: true);
|
||||||
|
|
||||||
|
$child->stdin?->write('Hello, this is pretty cool.');
|
||||||
|
$child->stdin?->close();
|
||||||
|
|
||||||
|
$output = $child->output();
|
||||||
|
|
||||||
|
var_dump($output)
|
||||||
|
|
||||||
|
// object(Nih\CommandBuilder\Output)#4 (3) {
|
||||||
|
// ["stdout"]=>
|
||||||
|
// string(27) "Hello, this is pretty cool."
|
||||||
|
// ["stderr"]=>
|
||||||
|
// string(0) ""
|
||||||
|
// ["code"]=>
|
||||||
|
// int(0)
|
||||||
|
// }
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user