PHPackages                             johnpbloch/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. [CLI &amp; Console](/categories/cli)
4. /
5. johnpbloch/php\_shell

AbandonedLibrary[CLI &amp; Console](/categories/cli)

johnpbloch/php\_shell
=====================

Run commands in a user environment from PHP

0.2.1(13y ago)4791GPLv3 or laterPHPPHP &gt;=5.3.2

Since May 18Pushed 13y ago1 watchersCompare

[ Source](https://github.com/johnpbloch/PHP_Shell)[ Packagist](https://packagist.org/packages/johnpbloch/php_shell)[ RSS](/packages/johnpbloch-php-shell/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

PHP Shell
=========

[](#php-shell)

PHP Shell is a [PSR-0 compliant](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) library for executing shell commands in a shell environment of your choosing (`bash` and `sh` currently supported).

Requirements
------------

[](#requirements)

- PHP 5.3 or higher
- `proc_open` and related functions

Installation
------------

[](#installation)

The recommended way to install PHP Shell is as a PEAR extension:

```
pear channel-discover johnpbloch.github.com/pear
pear install johnpbloch/PHP_Shell

```

Once installed, you can include the files in your project (assuming your PEAR directory is in the `include_path`):

```
include 'PHP_Shell/Shell.php';
include 'PHP_Shell/Bash.php';

```

Alternatively, you can use a PSR-0 compliant autoloader that checks your PEAR path. You can install one with PEAR:

```
pear channel-discover pear.phix-project.org
pear install phix/Autoloader

```

Include the above autoloader in your project:

```
require_once 'psr0.autoloader.php';

```

If you prefer to include the library source directly in your application, you may need to edit the `shell` executable file to change the location of your system's PHP binaries. By default, PHP Shell uses `/usr/bin/php`. Modify the first line of `PHP_Shell/shell` with the new location. Other than that, you should be able to drop this into your project and start using it in your code.

To find out where your system's PHP binary is, open a terminal window and run

which php

Use
---

[](#use)

Use the static `exec()` method of any class that extends `\PHP_Shell\Shell`. The first argument (which is required) is the command to execute. Any additional arguments will be parsed into the command using `vsprintf()` (`vsprintf()` will only be run if there are more than one argument).

```
use PHP_Shell\Bash;
// Using use:
echo Bash::exec('ls -la %s', escapeshellarg('.'));
// Using the fully qualified name:
echo \PHP_Shell\Sh::exec('git status');
```

(The code above assumes you have a PSR-0 compliant autoloader in place. If not, make sure you've included `PHP_Shell/Shell.php` as well as the file for the shell\[s\] you want to use.)

License
-------

[](#license)

PHP Shell is licensed under the [GPL version 3 or later](http://www.gnu.org/copyleft/gpl.html).

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

4791d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/044e10bd302ddb296511f2a463f61314bc17338c34fc0d292d05a425c655bc34?d=identicon)[johnpbloch](/maintainers/johnpbloch)

---

Top Contributors

[![johnpbloch](https://avatars.githubusercontent.com/u/446833?v=4)](https://github.com/johnpbloch "johnpbloch (3 commits)")

### Embed Badge

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

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.3k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71464.1k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20718.9k21](/packages/winbox-args)

PHPackages © 2026

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