首页 > 解决方案 > 如何在 codeigniter 中使用 phpseclib?

问题描述

我将phpseclib文件放在我的application/third_party文件夹中,我在控制器中包含了路径,如下所示

set_include_path(get_include_path() . PATH_SEPARATOR . 'third_party/phpseclib/Net/SSH2.php'); 

但我无法创建该类的实例。得到一个错误

找不到类 ssh2

最合适的使用方法是phpseclib什么?

标签: phpcodeigniterphpseclib

解决方案


After doing a lot of research, I finally found my problem. The problem was - i didn't add include the path after setting the set_include_path. Here is what I did-
1. I placed phpseclib files in my application/third_party folder.
2. In my controller, I set the include path as set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
3. After setting the path, I included the path as include_once(APPPATH.'third_party/phpseclib/Net/SFTP.php');
4. Now I can create my instance as $sftp = new Net_SFTP('your-host');
5. And connect my server as $sftp->login('user-name', 'password')


推荐阅读