kakawait/jumper

远程闭包执行器!

1.0.1 2014-03-21 11:18 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:44:10 UTC


README

Build Status Code Coverage Scrutinizer Quality Score Dependency Status

允许您通过SSH在其他远程计算机上执行PHP闭包,而不需要客户端/服务器设置。

源计算机依赖:PHP >= 5.3(可能在Windows上运行,但未经过测试)

目标计算机依赖:PHP >= 5.3,SSHd

<?php

require 'vendor/autoload.php';

$authentication = new \Jumper\Communicator\Authentication\Rsa('root', $_SERVER['HOME'] . '/.ssh/id_rsa');
$communicator = new \Jumper\Communicator\Ssh($authentication, array('host' => '127.0.0.1'));

$executor = new \Jumper\Executor($communicator, new Jumper\Stringifier\Native());

$array = array(2, 1, 4, 3);
$rsortedArray = $executor->run(
    function() use ($array) {
        rsort($array); 
        return $array;
    }
);

var_dump($rsortedArray);
// should print
/*
array(4) {
  [0]=>
  int(4)
  [1]=>
  int(3)
  [2]=>
  int(2)
  [3]=>
  int(1)
}
*/