achrafsoltani/sftp-service-provider
最新稳定版本:v2.0.0
Composer 安装命令:
composer require achrafsoltani/sftp-service-provider
包简介
SFTP Service Provider for Silex
README 文档
README
A Simple SFTP wrapper for Silex
Features
- Easy setup.
- Files : List, Upload, Download, Rename, Delete.
- Folders: List, Mkdir, Rename, Delete.
Requirements
- PHP 5.3+
- ext-ssh2
- monolog/monolog (through the MonologServiceProvider)
Dependencies
// Installing php-ssh2 $ sudo apt-get install libssh2-php // checking if all is good $ php -m |grep ssh2
Installation
$ composer require achrafsoltani/sftp-service-provider
Setup
require_once __DIR__.'/vendor/autoload.php';
use Silex\Application;
use AchrafSoltani\Provider\SftpServiceProvider;
use Silex\Provider\MonologServiceProvider;
$app = new Application();
// Monolog
$app->register(new Silex\Provider\MonologServiceProvider(), array(
'monolog.logfile' => __DIR__.'/logs/development.log',
));
// SFTP
$app->register(new SftpServiceProvider(), array(
'sftp.options' => array(
'hostname' => 'domain.tld', // or IP address
'username' => 'root',
'password' => 'your_ssh_password',
'port' => '22' // optional
)
));
// Usage
$app->run();
Usage
- Example 1 : Listing files in a directory
$dirs = $app['sftp']->list_files('/home/user/');
var_dump($dirs);
- Example 2 : Downloading a File
$app['sftp']->download('/home/user/source_file.ext', '/home/user/path/to/destination/downloaded.ext');
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-28