2017 © Pedro Peláez
 

library cli-runtime

PHP runtime execute command library

image

johnitvn/cli-runtime

PHP runtime execute command library

  • Wednesday, July 22, 2015
  • by johnitvn
  • Repository
  • 1 Watchers
  • 2 Stars
  • 141 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

PHP Cli Runtime

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads, (*1)

PHP runtime execute command library, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist johnitvn/cli-runtime "*"

or add, (*5)

"johnitvn/cli-runtime": "*"

to the require section of your composer.json file., (*6)

Usage

  1. Create processor
$workingdir = 'path/to/working_dir';
$process = new johnitvn\cliruntime\CliRuntimeProcess($workingdir);

If you set working dir is null in CliRuntimeProcess constructor current working dir will be path of file call CliRuntimeProcess, (*7)

  1. Run command without return and display ouput
$process->run('echo Hello');
  1. Run command with capture output
$output = array();
$process->runCapture('echo Hello',$output);
var_dump($output);

As example reference variable $ouput will get command output lines as array, (*8)

  1. Run command with display out put
$process->runDisplayOutput('echo Hello');

runDisplayout() will be run command and display out, (*9)

  1. Command Builder You can use johnitvn\cliruntime\CommandBuidler as utility for create command

Below is simple example with CommandBuilder:, (*10)

$command = new johnitvn\cliruntime\CommandBuidler('echo');
$command->addParam('Hello world');
echo $command->getCommand();

and the result is:, (*11)

echo Hello world

You can see below code snippet for understand how to use CommandBuilder class, (*12)

$builder = new CommandBuidler('phpunit');
$builder->addFlag('v')
    ->addArgument('stop-on-failure')
    ->addArgument('configuration', 'phpunit.xml')
    ->addParam('TestCase.php');
echo $builder->getCommand();

And the result is:, (*13)

phpunit TestCase.php -v --stop-on-failure --configuration=phpunit.xml
  1. CommandFinder (since version 1.0.2) You can use johnitvn\cliruntime\CommandFinder as utility for finder real path of command under system environment variable
use johnitvn\cliruntime\CommandFinder;
$realCommand = CommandFinder::findCommand('composer');
echo $realCommand;

And result look like: C:\\xampp\php\composer, (*14)

You can see the class comment for more detail about usage, (*15)

The Versions

22/07 2015

dev-master

9999999-dev

PHP runtime execute command library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.2

 

cli execute runtime

22/07 2015

1.0.2

1.0.2.0

PHP runtime execute command library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.2

 

cli execute runtime

22/07 2015

1.0.1

1.0.1.0

PHP runtime execute command library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.2

 

cli execute runtime

22/07 2015

1.0.0

1.0.0.0

PHP runtime execute command library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.2

 

cli execute runtime