marktaborosi/flysystem-nextcloud

A Flysystem v3 adapter for Nextcloud WebDav integration

1.0.0 2025-04-28 17:11 UTC

This package is auto-updated.

Last update: 2025-04-28 17:24:08 UTC


README

Author Latest Version Software License Downloads PHP 8.2+ CI

Flysystem adapter for Nextcloud WebDAV integration.

Compatible with PHP 8.2+ and Flysystem v3.29+.

Features

  • 📂 Nextcloud storage adapter for League\Flysystem
  • 🏗️ Fully tested with Flysystem adapter utilities + additional tests

Requirements

  • PHP 8.2 or higher
  • Flysystem v3.29+
  • Nextcloud instance (with WebDAV access)
  • Docker (for local testing)

Installation

composer require marktaborosi/flysystem-nextcloud

Usage

use League\Flysystem\Filesystem;
use Marktaborosi\FlysystemNextcloud\NextCloudAdapter;

$adapter = new NextCloudAdapter([
    'baseUri' => 'http://localhost:8080/remote.php/dav/files/admin/',
    'userName' => 'admin',
    'password' => 'admin',
]);

$filesystem = new Filesystem($adapter);

$filesystem->write('example.txt', 'Hello Nextcloud!');

Testing

This adapter includes a full test suite using league/flysystem-adapter-test-utilities.

Running tests locally

  1. Start the Docker containers:
docker-compose up -d
  1. Run PHPUnit:
vendor/bin/phpunit

Important: Ensure the Nextcloud container is running and fully initialized before executing the tests.

Docker Setup

Provided docker-compose.yml includes:

  • MariaDB database
  • Nextcloud app

Configuration expects:

  • Admin user: admin
  • Admin password: admin
  • DB credentials: see docker-compose.yml or .env.

Note: You can override port mappings easily via the .env file.
Example .env variables:

NEXTCLOUD_HTTP_PORT=8080
NEXTCLOUD_DB_PORT=3306

MYSQL_ROOT_PASSWORD=root_password
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=nextcloud_password

NEXTCLOUD_ADMIN_USER=admin
NEXTCLOUD_ADMIN_PASSWORD=admin

Accessing the Nextcloud Web Interface

Once the Docker containers are up, you can access the Nextcloud web interface locally:

http://localhost:[NEXTCLOUD_HTTP_PORT]

Default credentials:

  • Username: ${NEXTCLOUD_ADMIN_USER} (default: admin)
  • Password: ${NEXTCLOUD_ADMIN_PASSWORD} (default: admin)

You can login and interact directly with your running Nextcloud instance.

Suggested Packages

  • sabre/dav: Required for WebDAV communication
  • larapack/dd: Optional, for debugging purposes

License

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

Acknowledgements

Big thanks to:

This adapter would not be possible without these open-source projects. 🙏

Made with ❤️ by Mark Taborosi