├── .gitignore ├── LICENSE ├── README.md ├── composer.json └── src └── Neoxia └── Filesystem └── SftpServiceProvider.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | /vendor 4 | composer.lock 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Neoxia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :warning: The SFTP service provider is present natively in Laravel since [v5.6.7](https://github.com/laravel/framework/releases/tag/v5.6.7). You should avoid using this package if you are in a version of Laravel higher than this one. 2 | 3 | [![Latest Stable Version](http://img.shields.io/github/release/neoxia/laravel-sftp.svg)](https://packagist.org/packages/neoxia/laravel-sftp) 4 | 5 | ## Laravel SFTP 6 | 7 | This package provide a service provider to add the "sftp" driver to Laravel Storage. 8 | 9 | ## Installation 10 | 11 | Require this package with composer using the following command: 12 | 13 | ``` 14 | composer require neoxia/laravel-sftp 15 | ``` 16 | 17 | As of Laravel 5.5, this package will be automatically discovered and registered. 18 | For older version of Laravel, add the service provider in `config/app.php`. 19 | 20 | ```PHP 21 | Neoxia\Filesystem\SftpServiceProvider::class, 22 | ``` 23 | 24 | ## Configuration 25 | 26 | To configure a new Laravel storage disk on SFTP, provide a configuration like this one in `config/filesystems.php` 27 | 28 | ```PHP 29 | 'disks' => [ 30 | 31 | 'sftp' => [ 32 | 'driver' => 'sftp', 33 | 'host' => env('SFTP_HOST', ''), 34 | 'port' => env('SFTP_PORT', '21'), 35 | 'username' => env('SFTP_USERNAME', ''), 36 | 'password' => env('SFTP_PASSWORD', ''), 37 | 'privateKey' => env('SFTP_PRIVATE_KEY_PATH', ''), 38 | 'root' => env('SFTP_ROOT', ''), 39 | 'timeout' => env('SFTP_TIMEOUT', '10'), 40 | ], 41 | 42 | ], 43 | ``` 44 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "neoxia/laravel-sftp", 3 | "license": "MIT", 4 | "description": "SFTP filesystem service provider for Laravel", 5 | "require": { 6 | "php": ">=5.5.9", 7 | "illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", 8 | "illuminate/filesystem": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*", 9 | "league/flysystem-sftp": "1.0.*" 10 | }, 11 | "autoload": { 12 | "psr-4": { 13 | "Neoxia\\": "src/Neoxia/" 14 | } 15 | }, 16 | "extra": { 17 | "laravel": { 18 | "providers": [ 19 | "Neoxia\\Filesystem\\SftpServiceProvider" 20 | ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Neoxia/Filesystem/SftpServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->make('filesystem'); 19 | 20 | $filesystem->extend('sftp', function($app, $config) { 21 | return new Filesystem(new SftpAdapter($config)); 22 | }); 23 | } 24 | 25 | /** 26 | * Register bindings in the container. 27 | * 28 | * @return void 29 | */ 30 | public function register() 31 | { 32 | // 33 | } 34 | } 35 | --------------------------------------------------------------------------------