Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/rbarilani/nixshell

A minimalistic php object oriented ```exec``` wrap.
https://github.com/rbarilani/nixshell

Last synced: about 1 month ago
JSON representation

A minimalistic php object oriented ```exec``` wrap.

Awesome Lists containing this project

README

        

rbarilani/nixshell
==================

A minimalistic php object oriented ```exec``` wrap.

[![Build Status](https://travis-ci.org/rbarilani/nixshell.svg)](https://travis-ci.org/rbarilani/nixshell)
[![Code Coverage](https://scrutinizer-ci.com/g/rbarilani/nixshell/badges/coverage.png)](https://scrutinizer-ci.com/g/rbarilani/nixshell)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/rbarilani/nixshell/badges/quality-score.png)](https://scrutinizer-ci.com/g/rbarilani/nixshell)

## Install

Adds this to your composer.json and run ```composer update rbarilani/nixshell```:

```json
{
"require": {
"rbarilani/nixshell" : "dev-master"
},
"repositories" : [
{ "type":"git", "url":"https://github.com/rbarilani/nixshell.git" }
]
}
```

## Usage

```php
exec('ls');

$result->getExitCode(); // 0
$result->getOutput(); // ["dir1","dir2","etc"]

// unsuccessful command
try {
$shell->exec('cat not-existent-file');

}catch(ExecException $e) {

$e->getExitCode(); // 1
$e->getMessage(); // "cat: not-existent-file: No such file or directory (executed:'cat not-existent-file', exit code:1)"
$e->getOutput(); // [""cat: not-existent-file: No such file or directory"]
}

// history
$shell->getHistory(); // ["ls","cat not-existent-file"]

// clear history
$shell->clearHistory(); // []

```

## Development

Contributions are highly welcome.
Just clone the repository and submit your contributions as pull requests.