如何在Codeigniter中加载phpseclib [英] How to load phpseclib in codeigniter

查看:101
本文介绍了如何在Codeigniter中加载phpseclib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照标题,有人做到了吗?将这个库包含到codeigniter(v2.1.2)中的最佳实践是什么?

As per title, has anyone achieved this? What are the best practices on including this library into codeigniter (v2.1.2) ?

我知道可以像其他任何PHP应用程序一样简单地使用include / require语句来完成此操作,但是由于该项目一旦完成将移交给多个开发人员,所以我想确保它使用CI开发人员想要的设计模式正确构建。

I know it can be done by simply using include/require statements like any other PHP application, however as this project will be handed over to multiple devs once complete, I want to ensure it's built correctly using the design patterns the CI dev intended.

我已经尝试过测试控制器中的以下内容

I've tried the following in a test controller

public function index(){

    $this->load->library('phpseclib0.3.0/Net/SFTP');

}

但是我遇到了:


不存在的类:SFTP

Non-existent class: SFTP

phpseclib来自< a href = http://phpseclib.sourceforge.net/ rel = nofollow>此处。

phpseclib taken from here.

推荐答案

$ this-> load-> library 方法适用于codeigniter中已经存在的库。

the $this->load->library method is for libraries that already exist within codeigniter.

您可以为PHPSecLib类创建一个包装器,但是目前最简单的方法就是简单地将其包括在内。

You could create a wrapper for the PHPSecLib class, however what's probably easiest at the moment is to simply include it.


  1. 下载源代码fromm phpseclib的页面。

  2. 将其上传到/ application / third_party文件夹

  3. 包括文件。

  1. Download the source code fromm phpseclib's page.
  2. Upload it to the /application/third_party folder
  3. include the file.

include(APPPATH。'/third_party/phpseclib/Net/SSH2.php');

创建要使用的类的实例。

Create an instance of class your wanting to use.

这篇关于如何在Codeigniter中加载phpseclib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆