本文介绍了将phpseclib集成到Laravel 5中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将我的项目从Laravel 4迁移到Laravel 5,我仍然是Laravel和OOP的新手,但是到目前为止一切进展顺利.

i am currently migrating my Project from Laravel 4 to Laravel 5, i am still a novice user of Laravel and OOP as well but everything went smoothly so far.

但是,在我的L4项目中,我使用phpseclib生成了以以下方式导入的SSH密钥:

However, in my L4 project I use the phpseclib for generating SSH keys which I imported in the following way:

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

I know that there is a phpseclib package:https://packagist.org/packages/phpseclib/phpseclib

我也知道如何在我的L5项目中安装它.

and I also know how to Install it in my L5 Project.

但是,安装后,我不知道如何在Laravel 5项目中使用phpseclib软件包.

However, I dont know how to use the phpseclib package in my Laravel 5 project after I installed it.

因此,在我的L5项目中安装phpseclib软件包后,如何创建类似于以下内容的SSH密钥:

So, after I installed the phpseclib package in my L5 Project, how to create my SSH Key similar to this:

$rsa = new Crypt_RSA();

推荐答案

PHPSec确实使用了composer,您应该只能使用composer require "phpseclib/phpseclib=~0.3.10"并使它可用(自动加载).

PHPSec does use composer, you should be able to just composer require "phpseclib/phpseclib=~0.3.10" and have it available (autoloaded).

$rsa = new \Crypt_RSA();

这篇关于将phpseclib集成到Laravel 5中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 20:59