nulvem/remote
Composer 安装命令:
composer require nulvem/remote
包简介
SFTP/SSH client library for Laravel
README 文档
README
Remote is an SSH and SFTP connection package for the Laravel Framework. Our elegant solution simplifies even complex tasks with familiar Blade syntax. Experience easy, secure connections without tedious setup.
Installation
Install the composer package:
composer require nulvem/remote
Publish the configuration file:
artisan vendor:publish --provider="Nulvem\Remote\RemoteServiceProvider"
Configuration
Private key file
You can put your private key anywhere in the project, just point the key path in the file /config/remote.php:
[
'auth' => [
'key_path' => env('REMOTE_KEY_PATH', storage_path('id_rsa')),
],
];
The default path is /storage/id_rsa.
Default username
The default username is root, if you want to change it just add the following variable in the .env file:
REMOTE_USERNAME=dummy
Logging
If you want the log of all executions to be saved, just add the desired channel in the .env file.
REMOTE_LOG_CHANNEL=remote
It is recommended to add the following channel in the file /config/logging.php:
[
'channels' => [
'remote' => [
'driver' => 'daily',
'path' => storage_path('logs/remote.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
],
]
Usage
SSH
Generating scripts
To generate a new remote script use the following command:
php artisan make:remote-script hello-world
A file called hello-world.blade.php will be generated inside the /app/Scripts folder.
If you want to change the default scripts folder, just change the scripts_path property inside the file /config/remote.php.
Executing scripts
use Nulvem\Remote\Facades\Remote; $remote = Remote::ssh(host: '0.0.0.0'); $remote->run(script: 'hello-world');
If necessary, it is possible to change the default host port:
use Nulvem\Remote\Facades\Remote; $remote = Remote::ssh( host: '0.0.0.0', port: 2000 ); $remote->run(script: 'hello-world');
There is no default timeout, scripts may run forever, if necessary, it is possible to change the default host timeout:
use Nulvem\Remote\Facades\Remote; $remote = Remote::ssh( host: '0.0.0.0', timeout: 20 ); $remote->run(script: 'hello-world');
If necessary, it is possible to pass any parameters to the SSH script:
echo "Remote script 'install' started" echo "Hello, my name is {{ $name }}!" echo "I will list for you the files in the {{ $dir }} directory..." pwd echo "Remote script 'install' finished"
$remote = Remote::ssh(host: '0.0.0.0'); $remote->run( script: 'hello-world', data: [ 'name' => 'John Doe', 'dir' => '/var/www/html' ] )
Multiple actions on the same connection
use Nulvem\Remote\Facades\Remote; $remote = Remote::ssh(host: '0.0.0.0'); $remote->run(script: 'install-server'); someLogic(); $remote->run(script: 'configure-server');
SSH output
$remote = Remote::ssh(host: '0.0.0.0'); $execution = $remote->run(script: 'hello-world'); $execution->output(); $execution->success(); $execution->failed();
Warning
Do not remove the last line
Remote script 'SCRIPT_NAME' finishedon script files, if removed thesuccess()andfailed()methods of the output will not work correctly.
SFTP
Downloading files
use Nulvem\Remote\Facades\Remote; $remote = Remote::sftp(host: '0.0.0.0'); $remote->get( from: '/root/sample.json', to: storage_path('sample.json') );
Uploading files
use Nulvem\Remote\Facades\Remote; $remote = Remote::sftp(host: '0.0.0.0'); $remote->put(from: storage_path('sample.json'));
By default the /root path will be used, if you want to use a custom path:
use Nulvem\Remote\Facades\Remote; $remote = Remote::sftp(host: '0.0.0.0'); $remote->put( from: storage_path('sample.json'), to: '/var/www/html' );
Multiple actions on the same connection
use Nulvem\Remote\Facades\Remote; $remote = Remote::sftp(host: '0.0.0.0'); $remote->get( from: '/root/sample.json', to: storage_path('sample.json') ); someLogicToChangeSampleFile(); $remote->put(from: storage_path('sample.json'));
SFTP output
$remote = Remote::ssh(host: '0.0.0.0'); $execution = $remote->put(from: storage_path('sample.json')); $execution->success(); $execution->failed();
Security
If you've found a bug regarding security please mail tech@nulvem.com.br instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
nulvem/remote 适用场景与选型建议
nulvem/remote 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 4, 最近一次更新时间为 2023 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ssh」 「sftp」 「scp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nulvem/remote 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nulvem/remote 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nulvem/remote 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Typed PHP 8.2+ wrapper around ext-ssh2 that simplifies file upload/download over SSH/SCP/SFTP.
EIKONA Media deployer recipes
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
A flexible FTP, SSL-FTP, and SSH-based SFTP client for PHP. This lib provides helpers that are easy to use to manage the remote files.
Altax is an extensible deployment tool for PHP.
Wrapper class for PHP's SSH2 extension.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-02