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)023PHP

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 2w 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

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity61

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

2732d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5177606?v=4)[Wesley Guthrie](/maintainers/wesleywmd)[@wesleywmd](https://github.com/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

[seld/cli-prompt

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

24726.4M22](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

13045.3M6.2k](/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)
