convertain/laravel-nextcloud

Nextcloud WebDAV integration for Laravel.

Fund package maintenance!
Convertain

v1.0.1 2025-06-10 08:55 UTC

This package is auto-updated.

Last update: 2025-06-12 09:55:56 UTC


README

Latest Version on Packagist Total Downloads GitHub Stars License: MIT

Laravel Nextcloud

Nextcloud WebDAV integration for Laravel.

Features

  • Upload, download, list, move, copy, and delete files and directories on Nextcloud via WebDAV
  • Seamless integration with Laravel
  • Uses Flysystem for filesystem abstraction

Installation

Install via Composer:

composer require convertain/laravel-nextcloud

Configuration

To publish the package config file to your Laravel application's config directory, run:

php artisan vendor:publish --provider="Convertain\\NextcloudServiceProvider" --tag=nextcloud-config

This will create a config/nextcloud.php file in your application, which you can edit as needed.

return [
    'base_uri' => env('NEXTCLOUD_BASE_URI', ''),
    'username' => env('NEXTCLOUD_USERNAME', ''),
    'password' => env('NEXTCLOUD_PASSWORD', ''),
];

Alternatively, set the following environment variables in your .env:

NEXTCLOUD_BASE_URI=https://your-nextcloud-instance.com/remote.php/dav/files/
NEXTCLOUD_USERNAME=your-username
NEXTCLOUD_PASSWORD=your-password

Usage

Inject or instantiate the NextcloudService:

use Convertain\Nextcloud\Services\NextcloudService;

$nextcloud = new NextcloudService();

List Files

$files = $nextcloud->listFiles('path/to/dir');

List Directories

$dirs = $nextcloud->listDirectories('path/to/dir');

Upload File

$nextcloud->uploadFile('/local/path/file.txt', 'remote/path/file.txt');

Download File

$nextcloud->downloadFile('remote/path/file.txt', '/local/path/file.txt');

Delete File or Directory

$nextcloud->delete('remote/path/file.txt');

Create Directory

$nextcloud->createDirectory('remote/path/new-folder');

Check Existence

$exists = $nextcloud->exists('remote/path/file.txt');

Get File Content

$content = $nextcloud->getFileContent('remote/path/file.txt');

Move or Copy

$nextcloud->move('remote/path/file.txt', 'remote/path/new-file.txt');
$nextcloud->copy('remote/path/file.txt', 'remote/path/copy-file.txt');

License

MIT