Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dav Laravel Package

sabre/dav

sabre/dav is a popular PHP framework for building WebDAV, CalDAV, and CardDAV servers. It provides the core server stack plus extensions for calendars and contacts, with full documentation and installation guides at sabre.io.

View on GitHub
Deep Wiki
Context7

Getting Started

Install sabre/dav via Composer:

composer require sabre/dav

Begin with a minimal working WebDAV server using the included filesystem backend. Create server.php:

<?php
require 'vendor/autoload.php';

use Sabre\DAV;
use Sabre\DAVACL;

$server = new DAV\Server(
    new DAV\FS\Directory('/path/to/webdav/root')
);
$server->setBaseUri('/webdav/');

// Enable basic ACL support (optional but recommended)
$server->addPlugin(new ACL\Simple\ACL([
    'private' => ['{DAV:}read', '{DAV:}write'],
    'public'  => ['{DAV:}read'],
]));

$server->exec();

Run with PHP's built-in server:

php -S localhost:8000 server.php

First use case: verify access via browser at http://localhost:8000/webdav/ or using cadaver CLI tool:

cadaver http://localhost:8000/webdav/

Check documentation at https://sabre.io/dav/ — especially the Getting Started and Server chapters.

Implementation Patterns

Tree abstraction: All data (files, calendars, contacts) is modeled as a tree of INode implementations. Extend Node classes (Directory, File, Collection) or implement INode for custom storage.

Custom backend integration: Implement Backend\BackendInterface (for CardDAV/CalDAV) or extend Backend\AbstractBackend. Use PDO backends as reference (see sabre/dav/src/CalDAV/Backend/PDO.php). For high-performance, prefer iterators over arrays in getChildren().

Event-driven architecture: Leverage Sabre’s event system for hooks:

$server->on('beforeMethod', function ($methodName, $path) {
    if ($methodName === 'PROPFIND') {
        // Log property requests
    }
});

$server->on('afterGetProperties', function ($path, $properties, $outputProperties) {
    unset($outputProperties['{http://example.org}secret']);
});

Plugins: Extend PluginInterface to add features (e.g., custom headers, auth, sync). Key built-in plugins:

  • ACLPlugin — access control
  • CalDAV\Plugin — calendar scheduling, iTIP messages
  • CardDAV\Plugin — vCard imports/exports, addressbook-query
  • Browser — human-readable listing
  • Locks — file locking (requires Lock\BackendInterface)

Sync workflows: For incremental sync (CalDAV/CardDAV), implement getChanges() in your backend and use Sync\SyncPlugin. Support sync-token and sync-level REPORTs.

Integration tip: Wrap Sabre\DAV\Server in a Laravel controller or middleware. Use route groups for WebDAV paths (e.g., /dav/{user}). Inject auth via middleware and set $server->setBaseUri() dynamically.

Gotchas and Tips

Node path handling: Paths must be absolute and normalized (no .., leading /). The Tree resolves paths using getNodeForPath(). Override it for custom routing (e.g., per-user namespaces like /users/jane/). Caching here (getNodeForPath() caching in 4.7.0+) is critical for performance.

PHP 8.0+ deprecations: Ensure no implicit resource-to-string conversions. Common fixes: cast resources to strings (e.g., (string)$resource), and avoid gettype() comparisons — use is_*().

PROPFIND gotcha: When returning propstat elements, only one of {DAV:}prop or {DAV:}status per propstat. Multiple props in one response must be grouped under one prop.

Locks implementation: Locks require Lock\BackendInterface. Lock\Backend\AbstractBackend provides a DB-based implementation using MySQL/Postgres. Test with litmus test suite — locks and basic suites are critical.

CalDAV iTIP: To enable calendar invitations (e.g., meeting requests), configure IMipPlugin with a mailer (e.g., Symfony Mailer or SwiftMailer) and enable scheduling ($server->addPlugin(new CalDAV\Scheduling\Plugin())).

CardDAV filters: addressbook-query uses filter XML (e.g., {urn:ietf:params:xml:ns:carddav}address-data-filter). Avoid complex regex — use Sabre’s FilterParser where possible.

Extensibility: Override Sabre\DAV\PropFind methods like propFindUnfiltered() (4.6.0+) to bypass property filtering when needed. Use beforeMethod:* and method:* wildcards for events — 4.0+ dropped beforeMethod/method without wildcard.

Debug tip: Enable debug mode:

$server->on('exception', function ($e) {
    error_log($e->getTraceAsString());
});
$server->setDebugLevel(2); // Enable verbose logging

Use Server::addPlugin(new DAV\Browser\Plugin()) for browser GUI inspect requests/responses.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport