This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Command line helper

v1.0 2012-12-03 09:22 UTC

This package is not auto-updated.

Last update: 2021-09-17 23:12:10 UTC


Command line library for PHP that allows to call programs as functions.

Build Status

Inspired in Python Sh library (

usage examples:


// include PSR-0 autoloader
include __DIR__ . '/../vendor/autoload.php';

use Sh\Sh;

// Simple command using factory
echo Sh::factory()->runCommand('notify-send', array('-t', 5000, 'title', 'HOLA'));

// with instance
$sh  = new Sh();
echo $sh->ifconfig("eth0");

echo $sh->ls('-latr ~');

echo $sh->ls(array('-latr', '~'));

$sh->tail('-f /var/log/apache2/access.log', function ($buffer)  {
    echo $buffer;

// chainable commands (baking)
$sh->ssh(array('', '-p' => 1393))->whoami();
// executes: ssh -p 1393 whoami

$sh->ssh(array('', '-p' => 1393))->tail(array("/var/log/dumb_daemon.log", 'n' => 100));
// executes: ssh -p 1393 tail /var/log/dumb_daemon.log -n 100

Composer require:

        "gonzalo123/sh": "v1.0",