johnitvn/cli-runtime 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

johnitvn/cli-runtime

最新稳定版本:1.0.2

Composer 安装命令:

composer require johnitvn/cli-runtime

包简介

PHP runtime execute command library

README 文档

README

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads

PHP runtime execute command library

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"johnitvn/cli-runtime": "*"

to the require section of your composer.json file.

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

  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

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

runDisplayout() will be run command and display out

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

Below is simple example with CommandBuilder:

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

and the result is:

echo Hello world

You can see below code snippet for understand how to use CommandBuilder class

$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:

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

You can see the class comment for more detail about usage

统计信息

  • 总下载量: 320
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-07-22