marktaborosi / flysystem-nextcloud
A Flysystem v3 adapter for Nextcloud WebDav integration
Requires
- larapack/dd: ^1.1
- league/flysystem: ^3.29
- sabre/dav: ^4.7
Requires (Dev)
- league/flysystem-adapter-test-utilities: ^3.29
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
- larapack/dd: Optional debugging helper, useful for development.
- sabre/dav: Required for WebDAV communication with Nextcloud.
README
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
- Start the Docker containers:
docker-compose up -d
- 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 communicationlarapack/dd
: Optional, for debugging purposes
License
The MIT License (MIT). Please see License File for more information.
Acknowledgements
Big thanks to:
- The PHP League for creating and maintaining Flysystem.
- Nextcloud for providing an excellent WebDAV API.
This adapter would not be possible without these open-source projects. 🙏
Made with ❤️ by Mark Taborosi