2017 © Pedro Peláez
 

library hiatus

DEPRECATED: recommended to use symfony/process instead.

image

nubs/hiatus

DEPRECATED: recommended to use symfony/process instead.

  • Monday, July 7, 2014
  • by nubs
  • Repository
  • 0 Watchers
  • 0 Stars
  • 108 Installations
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Hiatus

A PHP library for executing shell commands with an optional timeout., (*1)

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., (*2)

Requirements

PHP 5.4 or newer is the only requirement for this library., (*3)

Installation

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

composer require nubs/hiatus

Usage

Composer's autoloader will automatically include the namespaced functions for use in your project., (*5)

Here's an example of how to execute a simple command:, (*6)

<?php
// 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:, (*7)

<?php
// 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(
    'curl',
    [$_POST['url']],
    10
);

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

echo $stdout;

An exception-generating variant is also included:, (*8)

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

echo $stdout;

Both exec and execX can be given a string to pass on stdin:, (*9)

<?php
list($exitStatus, $stdout, $stderr) = \Hiatus\exec(
    'wc -c',
    [],
    null,
    'stdin test'
);

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

Contributing

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

License

This project is licensed under the MIT License., (*11)

The Versions

07/07 2014

dev-master

9999999-dev

DEPRECATED: recommended to use symfony/process instead.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Spencer Rinehart

exec shell execution timeout

16/07 2013

1.2.1

1.2.1.0

A library for executing shell commands with an optional timeout.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Spencer Rinehart

exec shell execution timeout

16/07 2013

v1.2.0

1.2.0.0

A library for executing shell commands with an optional timeout.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Spencer Rinehart

exec shell execution timeout

15/07 2013

v1.1.0

1.1.0.0

A library for executing shell commands with an optional timeout.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Spencer Rinehart

exec shell execution timeout

15/07 2013

v1.0.0

1.0.0.0

A library for executing shell commands with an optional timeout.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Spencer Rinehart

exec shell execution timeout