Skip to content

Instantly share code, notes, and snippets.

@toin0u
Created February 17, 2015 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toin0u/5c9e709dd2a0cb9f63b0 to your computer and use it in GitHub Desktop.
Save toin0u/5c9e709dd2a0cb9f63b0 to your computer and use it in GitHub Desktop.
Flysystem ~1.0 + SFTP adapter
{
"require": {
"league/flysystem": "~1.0",
"league/flysystem-sftp": "~1.0"
}
}
<?php
require __DIR__ . '/vendor/autoload.php';
use League\Flysystem\Filesystem;
use League\Flysystem\Sftp\SftpAdapter;
$filesystem = new Filesystem(new SftpAdapter(array(
'host' => '11.22.33.44',
'port' => 1234,
'username' => 'username',
// 'password' => 'password-if-needed',
'privateKey' => '/Users/antoine/.ssh/id_rsa',
'root' => '/home',
'timeout' => 5,
)));
$isOk = $filesystemTest->write('foo.txt', 'foo, bar, baz !');
var_dump($isOk); // bool(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment