Implementing a WebDAV filesystem with PHP and SabreDAV
To being with our WebDAV implementation, there are several preliminary steps we must perform. These are:
- Create a new virtual host for your web drive
- Download and install SabreDAV
- Set permissions so web drive files on the web server can be updated
For the purposes of this article, we'll be setting up our WebDAV server to run on the URL
http://dav.example.com. The main directory of our WebDAV server will be at
/dav. Setting it up in this manner is a requirement of using Windows as a WebDAV client.
By the end of this argument we'll be able to map
http://dav.example.com/dav as a drive on our local computer.
Windows does not allow you to perform any operations on items in the root directory of a web site. It does however query the root directory to find out which paths within it can be mapped.
http://dav.example.com as an example. If you were to connect to this URL as a web drive in Windows, it would list our
dav directory as the only folder that can be accessed. You cannot create new folders (or files) in this root directory.
In order to set up a WebDAV site we must set up a new virtual host on your web server. Due to some limitations with the native Windows WebDAV client, the WebDAV server must reside at the root of the host it is on.
Additionally, Windows does not allow any operations to be performed on items in the root directory. All operations must take place on items in sub-directories.
Furthermore, the server must either be on port 80 or port 443 (for SSL only). Windows only allows basic HTTP authentication when using SSL - for non-SSL you must either have no authentication, or use digest authentication. We'll talk more about this soon.
You can read more notes about using Windows as a WebDAV client on the SabreDAV Wiki at http://code.google.com/p/sabredav/wiki/Windows.