问题
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.
- Download the source code fromm phpseclib's page.
- Upload it to the /application/third_party folder
include the file.
include(APPPATH . '/third_party/phpseclib/Net/SSH2.php');
Create an instance of class your wanting to use.
来源:https://stackoverflow.com/questions/11950934/how-to-load-phpseclib-in-codeigniter