-
Notifications
You must be signed in to change notification settings - Fork 19
How To Setup
Extract the contents of the cakeftp package into app/Plugin/Ftp/ or use git clone or git submodule in your plugins folder:
cd app/Plugin
git clone git://github.com/shama/cakeftp.git Ftp
The simplest way to setup a connection is to create a config named 'cakeftp'. Add the following to your app/Config/database.php file:
public $cakeftp = array(
'datasource' => 'Ftp.FtpSource',
'host' => 'example.com',
'username' => 'testuser',
'password' => '1234',
'type' => 'ftp',
);
You can setup multiple connections and decide which one you want to use later as well. For example in your app/Config/database.php file:
public $example_com = array(
'datasource' => 'Ftp.FtpSource',
'host' => 'example.com',
'username' => 'testuser',
'password' => '1234',
'type' => 'ftp',
);
public $test_com = array(
'datasource' => 'Ftp.FtpSource',
'host' => 'test.com',
'username' => 'testuser',
'password' => '1234',
'type' => 'ssh',
);
Then later to connect with the test_com connection do (Ftp being the name of the model):
$this->Ftp->useDbConfig = 'test_com';
You can also dynamically connect at any time. First just make sure you don't have a config named 'cakeftp' in your app/Config/database.php file. Then use the following code to connect (Ftp being the name of the model):
$connected = $this->Ftp->connect(array(
'host' => 'example.com',
'username' => 'user',
'password' => '1234',
'type' => 'ssh',
));
This plugin uses phpseclib, a pure-PHP secure communications library written by TerraFrost (Jim Wigginton). With 2.0 you no longer have to download/extract the library. It is included in this plugin.
public $cakeftp = array(
'datasource' => 'Ftp.FtpSource',
'host' => 'example.com',
'username' => 'testuser',
'password' => '1234',
'type' => 'ftp',
// FTP SPECIFIC
'passive' => true, // PASSIVE MODE
'timeout' => 5, // IN SECONDS
// LS CMD: Set to the dir listing command of your choice
'ls_cmd' => 'ls -l -A --time-style=long-iso',
/**
* CACHING
* Set the name of a cache config or
* set to true to use the default cakeftp one
*/
'cache' => false,
);
Check the Controller/ClientController.php or the test cases in the package for examples.