phpseclib 给我一个奇怪的错误

phpseclib gives me a strange erros

我正在尝试使用它,但它只是给我这个错误,我不知道如何解决这个问题..

Warning: include_once(Math/BigInteger.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 891

Warning: include_once(): Failed opening 'Math/BigInteger.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 891

Warning: include_once(Crypt/Random.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 895

Warning: include_once(): Failed opening 'Crypt/Random.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 895

Warning: include_once(Crypt/Hash.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 899

Warning: include_once(): Failed opening 'Crypt/Hash.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 899

Warning: include_once(Crypt/Base.php): failed to open stream: No such file or directory in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 904

Warning: include_once(): Failed opening 'Crypt/Base.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 904

Fatal error: Call to undefined function phpseclib_resolve_include_path() in /home/www/sfs_web/statistics/_public/_functions/Server/Net/SSH2.php on line 1226

include('Net/SSH2.php');
$ssh = new Net_SSH2('host');
if (!$ssh->login('user', 'pass')) {
  echo('Login Failed');
}

$ssh->exec('the cmd line...");
$ssh->disconnect();

phpseclib 可能不在您的 include_path 中。引用 phpseclib.sourceforge.net,

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');

include('Net/SSH2.php');
?>

您需要适当地进行调整。如果 phpseclib 在 vendor/phpseclib 目录中,则执行 'vendor/phpseclib',等等

是的,你需要 set_include_path。 而且,以我的方式,我在 ssh2.php 中替换了所有包含指令

include_once(Math/BigInteger.php)

stream_resolve_include_path(Math/*****.php)

对于 CodeIgniter <=3,

set_include_path(get_include_path() . PATH_SEPARATOR . APPPATH.'libraries/phpseclib');