My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
GettingStarted  
Quick setup for SabreDAV
Phase-Implementation, Featured
Updated Mar 21, 2012 by evert...@gmail.com

Getting Started

Before starting this tutorial, make sure you have completed the Installation steps.

Tutorial setup

Create an empty project directory. You should make sure this is accessable by your browser.

You can test if installation was succesful by creating a small php file containing the following:

<?php

include 'Sabre/autoload.php';
echo 'SabreDAV ', Sabre_DAV_Version::VERSION, ' is installed.';

?>

Note: If you did a manual installation you might need to include the full path to Sabre/autoload.php

Next, create two directories called 'data' and 'public'. We're going to use the 'public' directory to share files through WebDAV, 'data' is for other information. Make sure both folders are writable by the server. Depending on your choice of operating system this could be 'www-data', 'apache', 'httpd' or the 'nobody' user.

If you're not sure how to do this, please consult your system administrator.

Next, we're going to create the server.php file. This is an example of such a file:

<?php

// Files we need

require_once 'Sabre/autoload.php';

// Now we're creating a whole bunch of objects

// Change public to something else, if you are using a different directory for your files
$rootDirectory = new Sabre_DAV_FS_Directory('public');

// The server object is responsible for making sense out of the WebDAV protocol
$server = new Sabre_DAV_Server($rootDirectory);

// If your server is not on your webroot, make sure the following line has the correct information

// $server->setBaseUri('/~evert/mydavfolder'); // if its in some kind of home directory
// $server->setBaseUri('/dav/server.php/'); // if you can't use mod_rewrite, use server.php as a base uri
// $server->setBaseUri('/'); // ideally, SabreDAV lives on a root directory with mod_rewrite sending every request to server.php

// The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different 
// directory, if you're storing your data somewhere else.
$lockBackend = new Sabre_DAV_Locks_Backend_File('data/locks');
$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);

$server->addPlugin($lockPlugin);

// All we need to do now, is to fire up the server
$server->exec();

?>

Client Setup

Now you have your SabreDAV installation running. You can open it up in the browser to see if everything went as expected. The following error should be displayed:

<?xml version="1.0"?>
<d:error>
<s:exception>Sabre_DAV_Exception_NotImplemented</s:exception>
<s:message>GET is only implemented on File objects</s:message>
<s:file>/SabreDAV/lib/Sabre/DAV/Server.php</s:file>
<s:line>291</s:line>
<s:code>0</s:code>
</d:error> 

If you see anything else, something went wrong during setup. Now you can connect to the WebDAV server using your client. For more details, check the Client-specific pages:

Troubleshooting

WebDAV servers can be hard to debug, because the error messages reported by clients are often generic and cryptic. It is highly recommended to use a debugging proxy to find out whats going on over the wire. If your application returns an error, the debugging proxy is the tool to reveal it.

Some tools:

Thats it

Well, almost.. This WebDAV folder is wide open, everybody can read and write. Implement HTTP authentication to lock it down.

Next steps

Comment by emmanuel...@gmail.com, Apr 21, 2008

I have an error : Call to undefined method Sabre_DAV_FS_Directory::get()

Comment by project member evert...@gmail.com, Apr 21, 2008

Hi emmanuel,

You'll get that error when you try to open your sabredav installation through a webbrowser, which is not how its intended to be used..

Give it a shot using Finder (if you're on a mac) or DavFS2 (if you're on linux..) I realize I didn't include this in this tutorial, so I'll add that in..

Comment by emmanuel...@gmail.com, Apr 22, 2008

Thanks

Comment by iconara, May 27, 2008

After following these instructions my httpd spins out of control, repeatedly crashing every few seconds, even though it was minutes since I stopped trying to connect to the DAV server.

Apache/2.2.6 (installed with Darwin Ports on Mac OS X 10.5.2 connecting with Finder)

Comment by iconara, May 27, 2008

This is the message in apache's error_log:

child pid 16418 exit signal Segmentation fault (11)

Comment by project member evert...@gmail.com, May 27, 2008

Thats a nasty one, and usually means PHP goes into some infinite or recursive loop..

Do you know for which method it goes wrong? Is it straight on the first propfind or does it happen in a later stage? I'll go and test this on my Mac as well, so far i've only tried it on Debian. I'm sure you are, but make sure your running it on a PHP version in the 5.2. range

Comment by iconara, Jun 6, 2008

Sorry, I didn't extract more info than that. The crash was so hard I wasn't keen on trying again...

I was running PHP 5.2.5 installed via MacPorts? (php5 @5.2.5_1+apache2+macosx+mysql5+sqlite).

Comment by stephan....@gmail.com, Jun 29, 2008

works like a charm here, php-5.2.6 on gentoo linux, with a windows client.

evertpot, will there be a set of hooks which will let me do some actions on a delete/get/put or something? or do i have to write/extend my own driver for such things?

Comment by project member evert...@gmail.com, Jun 29, 2008

Hi Stephan,

To extend the webdav service with your own business logic, you have 2 choices. You can extend the Tree class, which basically gives you a method for every operation, or you can use the ObjectTree? and create your own File and Directory classes.

http://code.google.com/p/sabredav/wiki/ObjectTree

An example of how this is done can be seen in the FS/ directory.

Comment by iconara, Jul 1, 2008

The latest version (0.3.118) fixes the segmentation faults I was having.

Comment by iconara, Jul 1, 2008

A comment on the instructions: "This is how the file should look like" refers to a file that has not previously been mentioned. Perhaps it should be clarified which file this is, where it should be located, etc.

I have assumed that this is the script that is going to respond to the request and that it can be located anywhere as long as the paths to the various directories and SabreDAV code are right, but it is not at all clear and the current wording is confusing (cut and pasted from a longer description perhaps?).

Apart from that the instructions on this page are simple and give you just enough to get you started.

Comment by project member evert...@gmail.com, Jul 1, 2008

Glad the segmentation fault was fixed.. I'll be updating the docs shortly as well, it does actually seem like part of the documenation is missing altogether..

Comment by project member evert...@gmail.com, Jul 1, 2008

Made some updates to this page based on the suggestions. If anyone if you guys (theo or stephan) are interested in getting access and help out, please let me know! Very happy with you guys finding my mistakes :)

Comment by risto.ko...@gmail.com, Jul 28, 2008

I works perfectly. I tried to integrate it with my home made CMS and it works :) Unfortunately I had to change each require_once to get the right file. Did you think about any constant that would point to SabreDav? folder?

Comment by project member evert...@gmail.com, Jul 28, 2008

Hey Risto,

Adding a constant is a bit uncommon, it is generally recommended to make sure the library is in your 'include_path' instead. Once you got that, everything should work out of the box.

Evert

Comment by mike.gau...@gmail.com, Jul 27, 2009

Suggested tools:

Wireshark for protocol debugging and the REST Client Firefox plugin for making custom HTTP requests.

Comment by ekois...@gmail.com, Oct 17, 2009

Maybe fiddler proxy can help when debugging: some hints are on http://bit.ly/16htQ6

Comment by gurvinde...@gmail.com, May 28, 2010

Hi Evert,

I have downloaded your SabreDav?? software and thanks for the caldav support and your hard work. I have installed the sabredav on my web server and after running your test example, I get the output as

SabreDAV 1.2.0 is installed.

After that, I made the server file with name testserver.php and made the twi directories as suggested above. After that opened the testserver.php and I get the error message as

Sabre_DAV_Exception_FileNotFound?? File with name public/testserver.php could not be located 1.2.0

Can you tell me where I am doing some thing wrong. In the comment above you mentioned that Server should be run using davfs2 on linux, but how to do.

Thanks for your help !! Guri

Comment by project member evert...@gmail.com, May 28, 2010

Hi gurvindersinghdahiya,

Your baseUrl is wrong. Try setting it to 'public/testserver.php/'

Evert

Comment by sudhirconscious, May 31, 2010

Hi, It works great. But i've a problem regarding using SabreDAV with Openconnector for outlook calendar sync. Can we do this...? If yes then could you please tell me how to do it. As i tried to connect with open connector, its being connected, but as i pass the url as HOME URI, in my case: http://localhost/SabreDAV/calendarserver.php/calendars/admin/, the open connector shows only a folder and no calendar files, as the files are under /admin/default/ directory, how to do it..?

Comment by project member evert...@gmail.com, May 31, 2010

I've never tried using Openconnector. Perhaps you can try principals/admin instead of calendars/admin.

If you still have trouble, head over to the mailing list: http://groups.google.com/group/sabredav-discuss

and start debugging with Charles HTTP Proxy.

Comment by barbora....@gmail.com, Jun 3, 2010

same problem as @sudhirconscious :(

Comment by produkt...@infostig.se, Aug 25, 2010

I installd Sabre_DAV, Sabre_CalDAV by pear, and got this error message.

Sabre_DAV_Exception_Forbidden? Requested uri (/dav/server.php) is out of base uri (/storage/content/66/102766/produktion.infostig.se/public_html/dav/) 1.2.5

This is my baseurl in the webhotel: /storage/content/66/102766/produktion.infostig.se/public_html/

Webhotell call this root: /produktion.infostig.se/public_html/

My struktur of SabreDAV is after /public_html

/dav
  /data
  /public	
  server.php

/Sabre
  /CalDav
  /DAV
  /HTTP
  autoload.php
Comment by project member evert...@gmail.com, Aug 25, 2010

Mr. produktion,

The base uri is a uri, not a local path name. If you change the base uri to /dav/server.php/ you should be fine.

Evert

Comment by produkt...@infostig.se, Aug 25, 2010

Thanks! At least a new, error

Sabre_DAV_Exception_NotImplemented? GET is only implemented on File objects 1.2.5

Comment by project member evert...@gmail.com, Aug 25, 2010

This is correct. You are doing a GET request on a directory. You could add the browser plugin to get directory indexes.

Head over to the mailing list if you have more questions =)

Comment by davide.c...@gmail.com, Dec 20, 2010

Hi, a quick question, 'cause I really don't understand why $server->getRequestUri() is always empty

$rootDirectory = new Sabre_DAV_FS_Directory('public'); $server = new Sabre_DAV_Server($rootDirectory); $server->setBaseUri('/cad/sabreDAV/index.php/');

$browserPlugin = new Sabre_DAV_Browser_Plugin?();

$server->addPlugin($browserPlugin);

$server->exec();

Directory Structure:

/cad/sabreDAV/ here is index.php with server instantiation

/cad/sabreDAV/public Directory that I want to browse

Everything works fine, except that the browser plugin writes out

Index for /

Rather than Index for /public.

Why?

I appreciate any feedback.

Thank you, Davide

Comment by project member evert...@gmail.com, Dec 20, 2010

requestUri returns the url, relative to the baseuri.

Comment by davide.c...@gmail.com, Dec 20, 2010

Thanks for the reply but I can't get it...

If I see your online test example, I notice that it works perfectly.

Comment by project member evert...@gmail.com, Dec 20, 2010

head over to the mailing list, and provide more detail there.

Comment by kuno.me...@gmx.ch, Apr 9, 2011

This page should be updated to use non-deprecated APIs:

Sabre_DAV_Locks_Backend?_FS:

  • This Lock Manager is now deprecated. It has a bug that allows parent
  • collections to be deletes when children deeper in the tree are locked.
  • You are recommended to use either the PDO or the File backend instead.

Comment by project member evert...@gmail.com, Apr 9, 2011

Fixed, thank you

Comment by sadanmas...@gmail.com, Apr 19, 2011

Hi Evert,

I followed the procedure you mentioned above. I am getting the following result in the browser:

<d:error> <s:exception>Sabre_DAV_Exception_NotImplemented?</s:exception> <s:message>GET is only implemented on File objects</s:message> <s:sabredav-version>1.4.2</s:sabredav-version> </d:error>

This is slightly different from your result shown in the procedure. Can you tell me whether my installation is correct or am I missing something ??

Thanks

Sadan Masroor

Comment by sadanmas...@gmail.com, Apr 28, 2011

Hi Evert,

It is kindly requested to let me know that the result I am getting in my browser is as follows:

<d:error>

<s:exception>Sabre_DAV_Exception_NotImplemented?</s:exception> <s:message>GET is only implemented on File objects</s:message>
<s:sabredav-version>1.4.2</s:sabredav-version>
</d:error>

The above result is slightly different from the one you posted. Can you please let me know whether my installation is correct or not ?

Thank You

Sadan Masroor

Comment by project member evert...@gmail.com, Apr 29, 2011

Yup this is correct. Things changed over time =)

Comment by solin....@gmail.com, May 15, 2011

Hi Evert,

thanks for the great framework. As far as I understand, if I get this message, i should have sabredav installed successfully.

<d:error><s:exception>Sabre_DAV_Exception_NotImplemented?</s:exception><s:message>GET is only implemented on File objects</s:message><s:sabredav-version>1.4.3</s:sabredav-version></d:error>

But i can't connect via Mac OS X finder on my Snow Leopard. any ideas?

Comment by project member evert...@gmail.com, May 15, 2011

No ideas right off the bat; try adding the Sabre_DAV_Browser_Plugin? and see if that works; if you still have issues, go to the mailing list.

Comment by solin....@gmail.com, May 15, 2011

Hi Evert, thanks for you reply, I added Sabre_DAV_Browser_Plugin?, and find the problem is that I didn't set the right path for root directory.

Comment by market...@fede.org, Jun 10, 2011

The baseUri may be automatically guessed with :

$baseUri = substr(dirname(FILE), strlen(FILE) - strlen($SERVER['SCRIPT_NAME']));
Comment by johnn...@gmail.com, Sep 30, 2011

Took me 15 minutes to find the create table statement of the PDO to function

$tree = new Sabre_DAV_ObjectTree?(

new Sabre_DAV_FS_Directory('your_file_path')
);

$server = new Sabre_DAV_Server($tree);

$lock_db = new PDO('sqlite:'.'your_path'.DIRECTORY_SEPARATOR.'lockdb.sqlite');

$lock_db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

$lock_db->query('CREATE TABLE if not exists locks (id integer primary key asc, owner text, timeout text, created integer, token text, scope integer, depth integer, uri text)');

$backend = new Sabre_DAV_Locks_Backend?_PDO($lock_db);

$server->addPlugin(

new Sabre_DAV_Locks_Plugin?($this->backend)
);

Comment by project member evert...@gmail.com, Oct 1, 2011

John,

All the .sql files are in the examples directory.

Comment by maher.e...@gmail.com, May 10, 2012

hello I have a problem with saberdav especially the location of server.php file and project structure


Sign in to add a comment
Powered by Google Project Hosting