I want to develop a carddav server in php with SabreDav. I started with the example as provided by SabreDav and the explanation https://sabre.io/dav/carddav/
The source code
<?php
/*
Addressbook/CardDAV server example
This server features CardDAV support
*/
// settings
date_default_timezone_set('Europe/Amsterdam');
// Make sure this setting is turned on and reflect the root url for your WebDAV server.
// This can be for example the root / or a complete path to your server script
$baseUri = '/';
/* Database */
//$pdo = new PDO('sqlite:data/db.sqlite');
$pdo = new PDO('mysql:host=localhost', "user", "password");
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
//Mapping PHP errors to exceptions
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
// Autoloader
require_once 'vendor/autoload.php';
// Backends
$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
$principalBackend = new Sabre\DAVACL\PrincipalBackend\PDO($pdo);
$carddavBackend = new Sabre\CardDAV\Backend\PDO($pdo);
//$caldavBackend = new Sabre\CalDAV\Backend\PDO($pdo);
// Setting up the directory tree //
$nodes = [
new Sabre\DAVACL\PrincipalCollection($principalBackend),
// new Sabre\CalDAV\CalendarRoot($authBackend, $caldavBackend),
new Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend),
];
// The object tree needs in turn to be passed to the server class
$server = new Sabre\DAV\Server($nodes);
$server->setBaseUri($baseUri);
// Plugins
$server->addPlugin(new Sabre\DAV\Auth\Plugin($authBackend,'SabreDAV'));
$server->addPlugin(new Sabre\DAV\Browser\Plugin());
//$server->addPlugin(new Sabre\CalDAV\Plugin());
$server->addPlugin(new Sabre\CardDAV\Plugin());
$server->addPlugin(new Sabre\DAVACL\Plugin());
$server->addPlugin(new Sabre\DAV\Sync\Plugin());
// And off we go!
$server->exec();
When accessing https://localhost/addressbookserver.php, I got the response
<s:sabredav-version>4.4.0</s:sabredav-version>
<s:exception>Sabre\DAV\Exception\NotFound</s:exception>
<s:message>File not found: addressbookserver.php in 'root'</s:message>
</d:error>
I had expect a dialog to enter the credentials and not the xml as returned as described in the documentation. The webserver log does not contain any errors. The addressbookserver.php does exist. It is the url which is called from the browser.
What is wrong here?