user1197220 user1197220 - 5 months ago 176
PHP Question

How to load phpseclib in codeigniter

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(){



However I'm greeted with:

Non-existent class: SFTP

phpseclib taken from here.


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.