Posts Tagged ‘webDav’

PHP with WebDAV

October 31st, 2010

The PHP WebDAV extension allows easy access to remote resources with PHP through the DAV protocol.

Installation and sample usage

This extension requires the Neon library and the related header files.

Neon can be downloaded from: http://www.webdav.org/neon/

Pre-built packages and ports are already available for most operating systems
and distributions.

In order to compile and install the PHP WebDAV extension, just follow the
standard PECL procedure :

$ phpize
$ ./configure –enable-dav
# make install

On OpenBSD systems, use

$ env AUTOCONF_VERSION=2.61 phpize

(replace 2.61 with any of the currently installed versions of autoconf on your system)

Basic example

webdav_connect(‘http://webdav.example.com/dav’, ‘davuser’, ‘davpassword’);
$a = webdav_get(‘/my/nice/object.txt’);
webdav_put(‘/your/nice/thing.txt’, $data);
webdav_unlink(‘/unwanted_resource.txt’);
webdav_rename(‘/dir/old_name’, ‘/dir/new_name’);
webdav_copy(‘/dir/orig_dir’, ‘/dir/new_dir’, TRUE);
webdav_close();

Named resource example

$res = webdav_connect(‘http://webdav.example.com/dav’, ‘davuser’, ‘davpassword’);
$a = webdav_get(‘/my/nice/object.txt’, $res);
webdav_put(‘/your/nice/thing.txt’, $data, $res);
webdav_unlink(‘/unwanted_resource.txt’, $res);
webdav_rename(‘/dir/old_name’, ‘/dir/new_name’, $res);
webdav_copy(‘/dir/orig_dir’, ‘/dir/new_dir’, TRUE, $res);
webdav_close($res);

Install WebDAV in apache Servers

October 29th, 2010

Download the Apache Web Server source code from the Apache website, e.g. httpd-2.x.x.tar.gz. The mod_dav module is inlcuded with the Apache 2 distribution. Configure and compile Apache:

./configure –prefix=/usr/local/apache2 –with-dav –enable-dav
(./configure –prefix=/usr/local/apache2 –with-dav –enable-dav –enable-proxy –enable-proxy-http)
make
make install
/usr/local/apache2/bin/httpd -l | grep dav

You need to reconfigure Apache:

DAVLockDB /usr/local/apache2/logs/DavLock
<Directory “/usr/local/apache2/htdocs”>
Dav On
</Directory>