This package is abandoned and no longer maintained. The author suggests using the symfony/process package instead.

DEPRECATED: recommended to use symfony/process instead.

1.2.1 2013-07-16 15:22 UTC

This package is auto-updated.

Last update: 2021-01-12 13:53:23 UTC


A PHP library for executing shell commands with an optional timeout.

DEPRECATED: This library is no longer being actively maintained. symfony/process has all the features of Hiatus and more. It is recommended as an alternative.


PHP 5.4 or newer is the only requirement for this library.


This package uses composer so you can just add nubs/hiatus as a dependency to your composer.json file or execute the following command:

composer require nubs/hiatus


Composer's autoloader will automatically include the namespaced functions for use in your project.

Here's an example of how to execute a simple command:

// Get the directory listing of the directory given by the user.
// NOTE: This is probably not a good idea to let users run arbitrary directory
// listings.
list($exitStatus, $stdout, $stderr) = \Hiatus\exec('ls -l', [$_POST['dir']]);

if ($exitStatus !== 0) {
    throw new Exception('Command failed.');

echo $stdout;

Including a timeout is simple:

// Download the url given by the user, but fail if it takes more than 10
// seconds.
// NOTE: This is probably not a good idea to let users download arbitrary urls.
list($exitStatus, $stdout, $stderr) = \Hiatus\exec(

if ($exitStatus !== 0) {
    throw new Exception('Command failed.');

echo $stdout;

An exception-generating variant is also included:

try {
    list($stdout, $stderr) = \Hiatus\execX('ls /foo');
} catch (Exception $e) {
    echo "Error occurred: {$e->getMessage()}\n";

echo $stdout;

Both exec and execX can be given a string to pass on stdin:

list($exitStatus, $stdout, $stderr) = \Hiatus\exec(
    'wc -c',
    'stdin test'

if ((int)$stdout !== 10) {
    echo "Well, this is awkward.\n";


Any changes, suggestions, or bug reports are welcome to be submitted on github. Pull requests are encouraged!


This project is licensed under the MIT License.