承接 voipforall/tftp-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

voipforall/tftp-client

最新稳定版本:v1.0

Composer 安装命令:

composer require voipforall/tftp-client

包简介

The missing PHP TFTP Client package compliant with RFC 1350

README 文档

README

TFTP Client for Laravel

Latest Version on Packagist Total Downloads GitHub Actions

A PHP TFTP Client compliant with the RFC 1350 compatible with Laravel Framework

Installation

You can install the package via composer:

composer require voipforall/tftp-client

Requirements

  • PHP ^8.1 (with ext-sockets enabled)
  • Laravel 10.x

Quick start

Configure in your .env file the following entries

TFTP_HOST=127.0.0.1
TFTP_PORT=69

To upload files

use VoIPforAll\TFTPClient\TFTPClient;

$client = new TFTPClient;
$response = $client->put('path/to/your/file-to-send.txt');

dd($response) -> true

the put method will return a boolean accordingly with the success of the operation.

To download files

use VoIPforAll\TFTPClient\TFTPClient;

$client = new TFTPClient;
$content = $client->get('file-to-download.txt');

dd($content) -> "Download Ok"

The get method will return false if something goes wrong, if the file exists and is readable will be returned its content.

Publish the config file

To publish the config file use the Artisan command vendor:publish to copy the config file to your project

php artisan vendor:publish --tag=config

or

php artisan vendor:publish --provider=VoIPforAll\\TFTPClient\\TFTPClientServiceProvider

Multiples TFTP Connections

You can have multiple connections with different TFTP Servers, take a look in the tftp-client.php config file

    /*
    |--------------------------------------------------------------------------
    | Default TFTP Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the TFTP connections below you wish
    | to use as your default connection for all TFTP operations. Of
    | course you may add as many connections you'd like below.
    |
    */

    'connection' => env('TFTP_CLIENT_CONNECTION', 'default'),

    /*
    |--------------------------------------------------------------------------
    | TFTP Connections
    |--------------------------------------------------------------------------
    |
    | Below you may configure each TFTP connection your application requires
    | access to. Be sure to include a valid base HOST and TRANSFER MODE,
    | otherwise you may not be able to connect in the server.
    |
    */

    'connections' => [

        'default' => [
            'host' => env('TFTP_HOST', '127.0.0.1'),
            'port' => env('TFTP_PORT', 69),
            'transfer_mode' => env('TFTP_TRANSFER_MODE', TransferModeEnum::OCTET->value),
        ],

        'custom' => [
            'host' => env('TFTP_CUSTOM_HOST', 'tftp.myhost.com'),
            'port' => env('TFTP_CUSTOM_PORT', 69),
            'transfer_mode' => env('TFTP_CUSTOM_TRANSFER_MODE', TransferModeEnum::OCTET->value),
        ],

    ],

The available transfer modes are:

  • netascii
  • octet (default)
  • mail

Check the RFC 1350 to more details about the transfer mode

Logging the operations

If you want to log all TFTP operations just set the TFTP_LOGGING to true in your .env file. You can also select the appropriate log channel using the TFTP_LOGGER_CHANNEL, the defalt log channel will be used if you leave this unset.

    /*
    |--------------------------------------------------------------------------
    | TFTP Logging
    |--------------------------------------------------------------------------
    |
    | When TFTP_LOGGING is enabled, all connections and transfers
    | operations are logged using the application logging
    | driver selected in TFTP_LOGGER_CHANNEL. This
    | can assist in debugging issues and more.
    |
    */

    'logging' => env('TFTP_LOGGING', false),

    'logger_channel' => env('TFTP_LOGGER_CHANNEL', env('LOG_CHANNEL')),

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email cristiano@voipforall.com.br instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-24