Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ddrv/php-shell


https://github.com/ddrv/php-shell

Last synced: 3 days ago
JSON representation

Awesome Lists containing this project

README

        

# ddrv/shell

# Install

```text
composer require ddrv/shell
```

# Usage

## Local

```php
'test', 'APP_SECRET' => '$3cr3t'], true);

/* or
$shell = new Ddrv\Shell\LocalShell();
$shell
->setCwd('/tmp')
->setEnv('APP_ENV', 'test')
->setEnv('APP_SECRET', '$3cr3t')
->mergeErrorsAndOutput();
*/

$result = $shell->exec('ls -l');

var_dump($result->getExitCode()); // 0
var_dump($result->getOutput()); // list directories in /tmp
var_dump($result->getErrors()); // null
```

## Descriptors

```php
setDescriptor(new WritablePipe(), ShellInterface::DESCRIPTOR_INPUT);
$shell->setDescriptor(new File('/tmp/out.txt', 'a'), ShellInterface::DESCRIPTOR_OUTPUT);
$shell->setDescriptor(new ReadablePipe(), ShellInterface::DESCRIPTOR_ERRORS);
```