convertain / laravel-nextcloud
Nextcloud WebDAV integration for Laravel.
Fund package maintenance!
Convertain
Requires
- league/flysystem-webdav: ^3.0
Requires (Dev)
- calebdw/larastan-livewire: ^2.2
- larastan/larastan: ^3.4
- laravel/pint: ^1.22
- nesbot/carbon: ^3.9
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.2
- tomasvotruba/bladestan: ^0.11.3
README
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