How to load phpseclib in codeigniter

Deadly 提交于 2019-12-20 04:23:05

问题


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

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');

}

However I'm greeted with:

Non-existent class: SFTP

phpseclib taken from here.


回答1:


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

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

  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');

  4. Create an instance of class your wanting to use.



来源:https://stackoverflow.com/questions/11950934/how-to-load-phpseclib-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!