mxmilu666/nyadav 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mxmilu666/nyadav

最新稳定版本:v1.7

Composer 安装命令:

composer require mxmilu666/nyadav

包简介

The simple WebDAV client for PHP and Swoole

README 文档

README

NyaDAV

🐱 NyaDAV

✨ The simple WebDAV client for PHP and Swoole ✨

Features

  • 📄 Get file list
  • 📏 Get file size
  • 📥 Download files
  • 📤 Upload files
  • ❌ Delete files

Requirements

  • PHP 8.0+
  • Swoole 5.1.0+

Installation

You can install NyaDAV via Composer:

composer require mxmilu666/nyadav

Usage

Initialize the Client

use NyaDAV\NyaDAV;
use NyaDAV\NyaDAVException;

try {
    $dav = new NyaDAV('example.com', 80, false); // Set true for SSL
} catch (NyaDAVException $e) {
    echo $dav->err;
    //or
    echo 'Error: ' . $e->getMessage();
}

Set Client Settings

$dav->set([
    'auth' => [
        'username' => 'your-username',
        'password' => 'your-password'
    ],
    'depth' => 1
]);

Get File List

try {
    $files = $dav->getfilelist('/remote.php/webdav/');
    $dav->close();
    print_r($files);
} catch (NyaDAVException $e) {
    echo $dav->err;
    //or
    echo 'Error: ' . $e->getMessage();
}

Get File Size

$size = $dav->getfilesize('/remote.php/webdav/test.txt');
$dav->close();
echo 'File Size: ' . $size;

Download File

Local download:

$fileInfo = $dav->getfile('/remote.php/webdav/test.txt', 'local_test.txt');
$dav->close();
print_r($fileInfo);

Cloud download (302):

$fileInfo = $dav->getfile('/remote.php/webdav/test.txt');
$dav->close();
print_r($fileInfo);

Upload File

try {
    $success = $dav->uploadfile('/remote.php/webdav/uploaded.txt', 'local_upload.txt');
    $dav->close();
    if ($success) {
        echo 'File uploaded successfully!';
    }
} catch (NyaDAVException $e) {
    echo $dav->err;
    //or
    echo 'Error: ' . $e->getMessage();
}

Delete File

try {
    $success = $dav->deletefile('/remote.php/webdav/uploaded.txt');
    $dav->close();
    if ($success) {
        echo 'File deleted successfully!';
    }
} catch (NyaDAVException $e) {
    echo $dav->err;
    //or
    echo 'Error: ' . $e->getMessage();
}

File Exists

try {
    $success = $dav->file_exists('/remote.php/webdav/test.txt');
    $dav->close();
    if ($success) {
        echo 'exists';
    }
    else{
        echo 'not exist';
    }
} catch (NyaDAVException $e) {
    echo $dav->err;
    //or
    echo 'Error: ' . $e->getMessage();
}

Contributing

Feel free to contribute by opening issues or submitting pull requests. We welcome all contributions! 🌟

License

This project is licensed under the Apache-2.0 License.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-07-27