coffeemaru/shellos 问题修复 & 功能扩展

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

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

coffeemaru/shellos

最新稳定版本:1.2.0

Composer 安装命令:

composer require coffeemaru/shellos

包简介

A PHP system calls library that expose a simple interface

README 文档

README

An easy to use sdk to work with system commands calls.

Simple command call

To create any command we will use the shell function, this function create a instance that can be used to execute the command.

$command = shell("ls")
if($command->execute()) {
    echo $command->getOutputString();
}

The command isn't executed on the shell call, to execute the command we need to use the execute method. This method return true if the command result is a success code. The method getOutputString can be used to get all the output returned by the command, if we want each line of the command is possible use the getOutputLines method that returns an array with each line of the output.

$command = shell("ls")
if($command->execute()) {
    for($command->getOutputLines() as $line){
        echo $line;
    }
}

SSH connection.

Shellos support SSH remote execution via the SSHExecutor, if the SSHExecutor is configured as default executor the functions will send the commands over a SSH tunnel instead of being executed locally.

# first we need to inicialice the client with the server credentials.
$exec = new SSHExecutor($host, $port, $username, $password)
ShellCommand::setDefaultExecutor($exec);

# below this code all the `shell` functions call wills raise a ssh command on the remote host.
$command = ssh("ls -la")
if($command->execute()) { # <-- raise a ssh command 
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2022-08-17