PHPackages                             cullylarson/ssh-copy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. cullylarson/ssh-copy

ActiveLibrary[File &amp; Storage](/categories/file-storage)

cullylarson/ssh-copy
====================

A library for performing remote copies. Copy to/from local, to/from remote, and even between two remote machines.

v1.0.2(10y ago)0721MITPHPPHP &gt;=5.3.0

Since Sep 12Pushed 10y ago1 watchersCompare

[ Source](https://github.com/cullylarson/ssh-copy)[ Packagist](https://packagist.org/packages/cullylarson/ssh-copy)[ Docs](https://github.com/cullylarson/ssh-copy)[ RSS](/packages/cullylarson-ssh-copy/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (1)

SSH Copy
========

[](#ssh-copy)

A library for performing remote copies. Copy to/from local, to/from remote, and even between two remote machines.

Install
-------

[](#install)

```
curl -s http://getcomposer.org/installer | php
php composer.phar require cullylarson/ssh-copy

```

Construct
---------

[](#construct)

You'll do everything with an instance of `Cully\Ssh\Copier`. Its constructor takes three parameters:

1. **$sshSource** *(resource|null)* *(optional, default:null)* An SSH connection resource. If null, will assume the source is the local machine. If its a resource, will assume the source is a remote machine.
2. **$sshDestination** *(resource|null)* *(optional, default:null)* An SSH connection resource. If null, will assume the destination is the local machine. If its a resource, will assume the destination is a remote machine.
3. **$localTmp** *(string|null)* *(optional, default:null)* If copying between two remote machines, the copy will first transfer the files to from the remote source, to the local machine, and then to the remote destination. So, you need to provide a temporary folder to house the files locally.

`copy`
------

[](#copy)

The `Cully\Ssh\Copier::copy` function takes two arguments:

1. **$sourceFilepath** *(string|array)* *(required)* The path to the file that you want to copy from the source machine. Instead of passing a single path, you can pass an array of paths to files you want to copy. If an array is provided, the **$destFilepath** parameter must also be an array of the same length.
2. **$destFilepath** *(string|array)* *(required)* The path on the destination machine, where you want the file copied. Instead of passing a single path, you can pass an array of paths to files you want to copy. If an array is provided, the **$sourceFilepath** parameter must also be an array of the same length.

**Returns:** *boolean* True on success, false on fail.

NOTE: Currently the `copy` function DOES NOT create parent folders. The folders must already exist. Maybe something for a future release.

`copyAssoc`
-----------

[](#copyassoc)

The `Cully\Ssh\Copier::copyAssoc` function is similar to `copy`, except it takes one argument:

1. **$sourceAndDest** *(array)* *(required)* An associative array where keys are source file paths, and values are destination file paths.

**Returns:** *boolean* True on success, false on fail.

Examples
--------

[](#examples)

### Setup SSH Connections

[](#setup-ssh-connections)

```
