dev-master
9999999-dev https://github.com/emmanuelroecker/php-sync-ftpSync local files with ftp server
MIT
The Requires
The Development Requires
file ftp sync
Wallogit.com
2017 © Pedro Peláez
Sync local files with ftp server
Synchronize local files with sftp (ssh ftp) server., (*2)
Compare dates between local and remote files, not using crc.(cyclic redundancy check), and update files only on remote sftp server., (*3)
This library can be found on Packagist., (*4)
The recommended way to install is through composer., (*5)
Edit your composer.json and add:, (*6)
{
"require": {
"glicer/sync-sftp": "dev-master"
},
"prefer-stable": true,
"minimum-stability": "dev"
}
And install dependencies:, (*7)
php composer.phar install
// Must point to composer's autoload file.
require 'vendor/autoload.php';
use GlSyncFtp\GlSyncFtp;
//init connection informations
$ftp = new GlSyncFtp("192.168.0.1", 22, "username", "password");
//launch synchronisation between local directory and remote files
$ftp->syncDirectory(
"/home/user/localDirectory", //local source directory
"/host/web/remoteDirectory", //remote destination directory
function ($op, $path) {
switch ($op) {
case GlSyncFtp::CREATE_DIR:
echo "Create Directory : ";
break;
case GlSyncFtp::DELETE_DIR:
echo "Delete Directory : ";
break;
case GlSyncFtp::DELETE_FILE:
echo "Delete File : ";
break;
case GlSyncFtp::UPDATE_FILE:
echo "Update File : ";
break;
case GlSyncFtp::NEW_FILE:
echo "New File : ";
break;
default:
}
echo $path . "\n";
}
);
//launch synchronisation between list of local directories and remote directories
$fps->syncDirectories(
[
"/home/user/localDirectory1" => "/host/web/remoteDirectory1",
"/home/user/localDirectory2" => "/host/web/remoteDirectory2"
],
function ($src, $dst) {
echo "Sync directory : $src with $dst";
},
function ($op, $path) {
switch ($op) {
case
GlSyncFtp::CREATE_DIR:
echo "Create Directory : ";
break;
case GlSyncFtp::DELETE_DIR:
echo "Delete Directory : ";
break;
case GlSyncFtp::DELETE_FILE:
echo "Delete File : ";
break;
case GlSyncFtp::UPDATE_FILE:
echo "Update File : ";
break;
case GlSyncFtp::NEW_FILE:
echo "New File : ";
break;
default:
}
echo $path . "\n";
}
);
Local ssh ftp server must be installed (On Windows, you can use cygwin openssh), (*8)
With Docker :, (*9)
(cd docker ; sudo tar xpvzf docker.tar.gz) docker pull rhasselbaum/scrappy-sftp docker run -d --name sftp -p 2022:22 -v /$(pwd)/docker/sftp-root:/sftp-root -v /$(pwd)/docker/credentials:/creds rhasselbaum/scrappy-sftp
Launch from command line :, (*10)
vendor\bin\phpunit
Change ftp server config in file : phpunit.xml.dist, (*11)
Authors : Emmanuel ROECKER & Rym BOUCHAGOUR, (*12)
Sync local files with ftp server
MIT
file ftp sync