PHPackages                             synapse/php-shell - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. synapse/php-shell

ActiveLibrary

synapse/php-shell
=================

PHP wrapper for executing shell commands

1.1.1(10y ago)23371MITPHP

Since Apr 15Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Synapse791/php-shell)[ Packagist](https://packagist.org/packages/synapse/php-shell)[ RSS](/packages/synapse-php-shell/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

PHP Shell
=========

[](#php-shell)

[![Build Status](https://camo.githubusercontent.com/7395150c7669f89a2cece7f8fc35db826d1bfad6b15052b1389b8aca2d873b8e/68747470733a2f2f7472617669732d63692e6f72672f53796e617073653739312f7068702d7368656c6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Synapse791/php-shell)

Introduction
------------

[](#introduction)

PHP Shell was written to provide an OOP wrapper around shell command execution in PHP. It enables you to receive a response object from the command execution containing the stdout, stderr and exit code of the command.

Documentation
-------------

[](#documentation)

#### Basic usage

[](#basic-usage)

To create the command, pass an absolute path to the command for instantiation. You can also set where the command is executed using the `setWorkingDirectory` method.

```
$pwd = new Neuron\Shell\Command('/bin/pwd'); // CommandNotFoundException if the command is not executable
$pwd->setWorkingDirectory('/tmp'); // DirectoryDoesNotExistException if the directory is not found
$output = $pwd->execute();
var_dump($output->getStdout()); // string(5) "/tmp"
var_dump($output->getStderr()); // string(0) ""
var_dump($output->getExitCode()); // int(0)
```

#### Adding flags

[](#adding-flags)

```
$cmd = new Neuron\Shell\Command('/usr/local/bin/my_command');
$cmd->addShortFlag('v');
$cmd->addShortFlag('c', '/tmp/test.json');
$cmd->addLongFlag('version');
$cmd->addLongFlag('config', '/tmp/test.json');
```

#### Adding Arguments

[](#adding-arguments)

```
$echo = new Neuron\Shell\Command('/bin/echo');
$echo->addArgument('hi there!');
```

#### Piping through another command

[](#piping-through-another-command)

```
$cmd = new Neuron\Shell\Command('/usr/local/bin/my_command');
$cmd2 = new Neuron\Shell\Command('/usr/local/bin/my_command2');
$cmd->pipe($cmd2);
echo $cmd->getCmdString(); // "/usr/local/bin/my_command | /usr/local/bin/my_command2"
```

#### Searching Output

[](#searching-output)

Check if the command was successful using the `wasSuccessful` method. Check if the output contains a certain string using the `stdoutContains` and `stderrContains` methods.

```
$echo = new \Neuron\Shell\Command('/bin/echo');
$echo->addArgument('fruit banana');
$output = $echo->execute();
var_dump($output->wasSuccessful()); // bool(true)
var_dump($output->stdoutContains('apple')); // bool(false)
var_dump($output->stdoutContains('banana')); // bool(true)
```

License
-------

[](#license)

PHP Shell is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

Changelog
---------

[](#changelog)

### 1.1.1

[](#111)

- Adding README info for pipe functionality

### 1.1.0

[](#110)

- Adding pipe functionality

### 1.0.0

[](#100)

- Initial Release

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

3679d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51b74c831b12bd303d7ded890ec188ad55d051d37683422736a9bc33ed3a5ecc?d=identicon)[synapse](/maintainers/synapse)

---

Top Contributors

[![itmecho](https://avatars.githubusercontent.com/u/8384983?v=4)](https://github.com/itmecho "itmecho (8 commits)")

### Embed Badge

![Health badge](/badges/synapse-php-shell/health.svg)

```
[![Health](https://phpackages.com/badges/synapse-php-shell/health.svg)](https://phpackages.com/packages/synapse-php-shell)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
