PHPackages                             wesleywmd/element-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. wesleywmd/element-shell

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

wesleywmd/element-shell
=======================

Simple library for running shell commands from PHP

1.0.0(7y ago)020PHP

Since Jan 7Pushed 7y ago1 watchersCompare

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

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

Shell Element
=============

[](#shell-element)

Library for running shell commands.

How to install the library
--------------------------

[](#how-to-install-the-library)

Install the library with composer

```
composer install wesleywmd/element-shell

```

How to create a command
-----------------------

[](#how-to-create-a-command)

Create a simple command with just a string.

```
$command = $commandFactory->create("ls -al");

```

Commands can have arguments. Add them via the factory.

```
$command = $commandFactory->create("ls", ["-al"]);

```

Or separate method.

```
$command = $commandFactory->create("ls");
$command->addArgument("-al");

```

You can define more than one argument with an array.

```
$command = $commandFactory->create("ls", ["-a", "-l"]);

```

or

```
$command = $commandFactory->create("ls");
$command->addArguments(["-a", "-l"]);

```

How to get a result object from the cli
---------------------------------------

[](#how-to-get-a-result-object-from-the-cli)

Once you have created you command, the next step is to run the command.

```
$result = $cli->execute($command);

```

Using the `execute()` method runs your command and then returns a result object. What happens if we want to be able to interact with our command? Then we need to you the `interact()` method. This will attach stdin and stdout to the process running the command.

```
$result = $cli->interact($command);

```

If you want to specify the directory to be in when running the command, specify it as the second parameter.

```
$result = $cli->execute($command, "~/path/to/use");

```

How to use the result object
----------------------------

[](#how-to-use-the-result-object)

You get a result object as the return from either the `execute()` or `interact()`. Your are able to get a lot of information about the command.

```
$result->getOriginalCommand();
$result->getOriginalCwd();
$result->getResponse();
$result->getExitCode();
$result->getStdErr();
$result->getExecutionTime();

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Unknown

Total

1

Last Release

2680d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c16e0882b007c73330869d5766ed95f27a6a336fb78f70f6729278f915963096?d=identicon)[wesleywmd](/maintainers/wesleywmd)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wesleywmd-element-shell/health.svg)

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

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M319](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M18](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

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