【发布时间】:2015-02-26 10:29:53
【问题描述】:
我目前正在将我的项目从 Laravel 4 迁移到 Laravel 5,我仍然是 Laravel 和 OOP 的新手用户,但到目前为止一切都很顺利。
但是,在我的 L4 项目中,我使用 phpseclib 生成 SSH 密钥,我通过以下方式导入:
MyController.php
...
include('../app/libs/phpseclib0.3.10/Crypt/RSA.php');
$rsa = new Crypt_RSA();
...
这似乎不再起作用了:
syntax error, unexpected 'if' (T_IF), expecting identifier (T_STRING)
.../app/libs/phpseclib0.3.10/Crypt/RSA.php
/**
* Include Crypt_Random
*/
// the class_exists() will only be called if the crypt_random_string function hasn't been defined and
// will trigger a call to __autoload() if you're wanting to auto-load classes
// call function_exists() a second time to stop the include_once from being called outside
// of the auto loader
if (!function_exists('crypt_random_string')) {
include_once 'Random.php';
}
我知道有一个phpseclib包: https://packagist.org/packages/phpseclib/phpseclib
我也知道如何在我的 L5 项目中安装它。
但是,我安装后不知道如何在我的 Laravel 5 项目中使用 phpseclib 包。
所以,在我的 L5 项目中安装了 phpseclib 包后,如何创建类似于此的 SSH 密钥:
$rsa = new Crypt_RSA();
【问题讨论】:
-
仅供参考,packagist.org URL 错误。这是packagist.org/packages/phpseclib/phpseclib。 phpsec/phpsec 是另一个不相关的项目。