CodeIgniter Forums
How to use phpseclib by composer - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: How to use phpseclib by composer (/showthread.php?tid=67373)



How to use phpseclib by composer - SirTom - 02-15-2017

Hi everybody,

I need some help... I install the phpseclib Modul by composer, but how can I use the Library???


Code:
include('Net/SFTP.php');

This Code will not work :-(

Thanks for your help!
Tom


RE: How to use phpseclib by composer - skunkbad - 02-15-2017

(02-15-2017, 06:33 AM)SirTom Wrote: Hi everybody,

I need some help... I install the phpseclib Modul by composer, but how can I use the Library???


Code:
include('Net/SFTP.php');

This Code will not work :-(

Thanks for your help!
Tom


In config/config.php:


PHP Code:
$config['composer_autoload'] = TRUE


It is especially important that your vendor directory be INSIDE your application directory, which means placing your composer.json file INSIDE the application directory. Run composer init inside the application directory if you don't already have a composer.json file there. Once you've created your composer.json and required phpseclib, make sure to run composer update.

Then inside your library, controller, model, etc:


PHP Code:
<?php
use \phpseclib\Net\SFTP;

class 
Whatever {

  public function doSftp(){
    $sftp = new SFTP('123.456.789.000''22''10');
    // now use SFTP ...
  }




RE: How to use phpseclib by composer - SirTom - 02-17-2017

Thanks!!!


RE: How to use phpseclib by composer - fconejerose - 07-20-2017

(02-15-2017, 09:51 AM)skunkbad Wrote:
(02-15-2017, 06:33 AM)SirTom Wrote: Hi everyody,

I need some help... I install the phpseclib Modul by composer, but how can I use the Library???


Code:
include('Net/SFTP.php');

This Code will not work :-(

Thanks for your help!
Tom


In config/config.php:


PHP Code:
$config['composer_autoload'] = TRUE


It is especially important that your vendor directory be INSIDE your application directory, which means placing your composer.json file INSIDE the application directory. Run composer init inside the application directory if you don't already have a composer.json file there. Once you've created your composer.json and required phpseclib, make sure to run composer update.

Then inside your library, controller, model, etc:


PHP Code:
<?php
use \phpseclib\Net\SFTP;

class 
Whatever {

  public function doSftp(){
    $sftp = new SFTP('123.456.789.000''22''10');
    // now use SFTP ...
  }



Excelent, thanks a lot skunkbad.
One Question: how about export variables in the remote conection?
somethink linke this:

$output = $ssh->exec(
   "set -e" . PHP_EOL
       . "export GRID_HOME=/u01/app/12.1.0/grid/bin/" . PHP_EOL
       . "cd \$GRID_HOME" . PHP_EOL
);

Not working for me :-(

Thanks again!


RE: How to use phpseclib by composer - skunkbad - 07-20-2017

(07-20-2017, 09:09 AM)fconejerose Wrote: Excelent, thanks a lot skunkbad.
One Question: how about export variables in the remote conection?
somethink linke this:

$output = $ssh->exec(
   "set -e" . PHP_EOL
       . "export GRID_HOME=/u01/app/12.1.0/grid/bin/" . PHP_EOL
       . "cd \$GRID_HOME" . PHP_EOL
);

Not working for me :-(

Thanks again!

I don't know. You probably need to ask on stack overflow or the phpseclib board.