8000 Initial commit · SimonFrings/reactphp-shell@4121d5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 4121d5c

Browse files
committed
Initial commit
0 parents  commit 4121d5c

16 files changed

+974
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: php
2+
php:
3+
- 5.3
4+
- 5.6
5+
- hhvm
6+
install:
7+
- composer update --prefer-source --no-interaction
8+
script:
9+
- phpunit --coverage-text

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# CHANGELOG
2+
3+
This file is a manually maintained list of changes for each release. Feel free
4+
to add your changes here when sending pull requests. Also send corrections if
5+
you spot any mistakes.
6+
7+
## 0.0.0 (2014-12-06)
8+
9+
* Initial concept

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Christian Lück
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is furnished
10+
to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# clue/shell-react [![Build Status](https://travis-ci.org/clue/php-shell-react.svg?branch=master)](https://travis-ci.org/clue/php-shell-react)
2+
3+
Run async commands within any interactive shell command, built on top of React PHP.
4+
5+
> Note: This project is in early alpha stage! Feel free to report any issues you encounter.
6+
7+
## Quickstart example
8+
9+
Once [installed](#install), you can use the following code to run an interactive
10+
bash shell and issue some commands within:
11+
12+
```php
13+
$loop = React\EventLoop\Factory::create();
14+
$launcher = new ProcessLauncher($loop);
15+
16+
$shell = $launcher->createDeferredShell('bash');
17+
18+
$shell->execute('echo -n $USER')->then(function ($result) {
19+
var_dump('current user', $result);
20+
});
21+
22+
$shell->execute('env | sort | head -n10')->then(function ($env) {
23+
var_dump('env', $env);
24+
});
25+
26+
$shell->end();
27+
28+
$loop->run();
29+
```
30+
31+
See also the [examples](examples).
32+
33+
## Install
34+
35+
The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)
36+
37+
```JSON
38+
{
39+
"require": {
40+
"clue/shell-react": "dev-master"
41+
}
42+
}
43+
```
44+
45+
## License
46+
47+
MIT

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "clue/shell-react",
3+
"description": "Run async commands within any interactive shell command",
4+
"keywords": ["interactive", "sheller", "ReactPHP", "async"],
5+
"homepage": "https://github.com/clue/php-shell-react",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Christian Lück",
10+
"email": "christian@lueck.tv"
11+
}
12+
],
13+
"autoload": {
14+
"psr-4" : { "Clue\\React\\Shell\\": "src/" }
15+
},
16+
"require": {
17+
"php": ">=5.3",
18+
"react/promise": "~1.0|~2.0",
19+
"react/child-process": "~0.3.0|~0.4.0",
20+
"react/stream": "~0.3.0|~0.4.0",
21+
"react/event-loop": "~0.3.0|~0.4.0"
22+
}
23+
}

composer.lock

Lines changed: 234 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bash.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use React\EventLoop\Factory;
4+
use Clue\React\Shell\ProcessLauncher;
5+
6+
require __DIR__ . '/../vendor/autoload.php';
7+
8+
$loop = Factory::create();
9+
$launcher = new ProcessLauncher($loop);
10+
11+
$shell = $launcher->createDeferredShell('bash 2>&1');
12+
13+
$shell->execute('echo -n $USER')->then(function ($result) {
14+
var_dump('current user', $result);
15+
});
16+
17+
$shell->execute('env | sort | head -n10')->then(function ($env) {
18+
var_dump('env', $env);
19+
});
20+
21+
$shell->end();
22+
23+
$loop->run();

examples/docker.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use React\EventLoop\Factory;
4+
use Clue\React\Shell\ProcessLauncher;
5+
6+
require __DIR__ . '/../vendor/autoload.php';
7+
8+
$loop = Factory::create();
9+
$launcher = new ProcessLauncher($loop);
10+
11+
$shell = $launcher->createDeferredShell('docker run -i --rm debian bash');
12+
13+
$shell->execute('id')->then(function ($result) {
14+
var_dump('current user', $result);
15+
});
16+
17+
$shell->execute('env')->then(function ($env) {
18+
var_dump('env', $env);
19+
});
20+
21+
$shell->end();
22+
23+
$loop->run();

0 commit comments

Comments
 (0)
0