php - 如何在 codeigniter 中使用 phpseclib?
问题描述
我将phpseclib
文件放在我的application/third_party
文件夹中,我在控制器中包含了路径,如下所示
set_include_path(get_include_path() . PATH_SEPARATOR . 'third_party/phpseclib/Net/SSH2.php');
但我无法创建该类的实例。得到一个错误
找不到类 ssh2
最合适的使用方法是phpseclib
什么?
解决方案
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')
推荐阅读
- c# - ASP Net Core SignInManager 未登录
- javascript - Javascript随机化图像(不显示相同的图像)
- c - rb_raise 之后的空闲字符串
- ansible - Ansible 获取清单主机组的主机名和 IP
- android - android sharedpreferences 颜色不起作用
- python - 如果新附加整数的值小于该列表的最大整数,如何清除列表中的所有整数
- gnuplot - 如何控制在 gnuplot 中打印多少 xlabel?
- uicollectionview - UIViewRepresentable 中的 UICollectionView 不会从 onAppear 滚动到项目
- r - 在 R 和 MarkDown 的同一图中绘制两个图,我对过去的答案有疑问
- java - 在另一个片段中使用 Firestore 回调