Giter Site home page Giter Site logo

rsync's Introduction

Rsync

License PHP 7 ready Build Status Codacy Grade Scrutinizer Code Quality Codacy Coverage Latest Stable Version Total Downloads

About

Rsync is a pure PHP 7.1+ dependency-free wrapper for rsync client. It provides you a simple way to abstract from command line control rsync right from php. Library uses PSR-4 autoloader standard and always has 100% tests coverage.
There is no need to tell about rsync, except the fact that php doesn't has any faster or equal built-in way to upload files to remote server.

Library supports whole bunch of options and parameters implemented in rsync client version 3.1.2

Why Rsync?

  1. It is small and fully covered with tests
  2. It is well documented
  3. I'm eating my own sweet pie=)
  4. Supports whole bunch of parameters and options of rsync and ssh
  5. Easy to use
  6. Works on Windows (ofcourse id you installed ssh and rsync clients for Windows)

Requirements

  • PHP 7.1+
  • PHP config variables_order must contain E, 4ex: variables_order=EGPCS.
    Otherwise you will have to manually specify absolute path to rsync and ssh binaries (at least on Windows)
  • rsync client 3.1.2 +

Installation

Install with composer

composer require xobotyi/rsync

Docs

The code is well documented, for methods and parameters descriptions see the sources.

Usage

Simplest:

use xobotyi\rsync\Rsync;

$rsync = new Rsync();
$rsync->sync('/path/to/source', '/path/to/destination');

If you need SSH:

use xobotyi\rsync\Rsync;
use xobotyi\rsync\SSH;

$rsync = new Rsync([
                       Rsync::CONF_CWD        => __DIR__,
                       Rsync::CONF_EXECUTABLE => '/even/alternative/executable/rsync.exe',
                       Rsync::CONF_SSH        => [
                           SSH::CONF_EXECUTABLE => '/even/alternative/executable/ssh.exe',
                           SSH::CONF_OPTIONS    => [
                               SSH::OPT_OPTION              => ['BatchMode=yes', 'StrictHostKeyChecking=no'],
                               SSH::OPT_IDENTIFICATION_FILE => './path/to/ident',
                               SSH::OPT_PORT                => 2222,
                           ],
                       ],
                   ]);
$rsync->sync('./relative/path/to/source', '[email protected]:/abs/path/to/destination');
echo './relative/path/to/source ' . ($rsync->getExitCode() === 0 ? 'successfully synchronized with remote.' : 'not synchronised due to errors.') . "\n";

$rsync->setExecutable('ssh')
      ->setOption(SSH::OPT_OPTION, false)// 'false' value turns off the options
      ->setOptions([
                       SSH::OPT_IDENTIFICATION_FILE => './new/path/to/ident',
                       SSH::OPT_PORT                => 22,
                   ]);
$rsync->sync('/new/path/to/source', '[email protected]:/abs/path/to/destination');
echo '/new/path/to/source ' . ($rsync->getExitCode() === 0 ? 'successfully synchronized with remote.' : 'not synchronised due to errors.') . "\n";

rsync's People

Contributors

russtaylor avatar xobotyi avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.