PHPackages                             coffeemaru/shellos - 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. coffeemaru/shellos

ActiveLibrary

coffeemaru/shellos
==================

A PHP system calls library that expose a simple interface

1.2.0(3y ago)064BSD-3-ClausePHPPHP &gt;=7.4

Since Sep 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/coffeemaru/shellos)[ Packagist](https://packagist.org/packages/coffeemaru/shellos)[ RSS](/packages/coffeemaru-shellos/feed)WikiDiscussions master Synced 1mo ago

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

Shellos
=======

[](#shellos)

An easy to use sdk to work with system commands calls.

Simple command call
-------------------

[](#simple-command-call)

To create any command we will use the `shell` function, this function create a instance that can be used to execute the command.

```
$command = shell("ls")
if($command->execute()) {
    echo $command->getOutputString();
}
```

The command isn't executed on the shell call, to execute the command we need to use the `execute`method. This method return true if the command result is a success code. The method `getOutputString`can be used to get all the output returned by the command, if we want each line of the command is possible use the `getOutputLines` method that returns an array with each line of the output.

```
$command = shell("ls")
if($command->execute()) {
    for($command->getOutputLines() as $line){
        echo $line;
    }
}
```

SSH connection.
---------------

[](#ssh-connection)

Shellos support SSH remote execution via the SSHExecutor, if the SSHExecutor is configured as default executor the functions will send the commands over a SSH tunnel instead of being executed locally.

```
# first we need to inicialice the client with the server credentials.
$exec = new SSHExecutor($host, $port, $username, $password)
ShellCommand::setDefaultExecutor($exec);

# below this code all the `shell` functions call wills raise a ssh command on the remote host.
$command = ssh("ls -la")
if($command->execute()) { #
