WebDAV can now be accessed through PHP. With this, you can make an excellent library in PHP. It allows you to make remote file systems in HTTP. Php WebDAV integrations are the next logical step

PHP WebDAV Setup

If you are going to set up PHP WebDAV, you can use the following PHP method:

<? Php

If ($_SERVER [‘REQUEST_METHOD’] === ‘OPTIONS’) {

header (‘Allows: OPTIONS GET HEAD POST DELETE’);

die ( );

GET

GET allows you to fetch the URIs content.

PUT

PUT is used to make a new resource or overwrite. In PHP, the data can be obtained with the use of:

<?php

$data = file_get_contents (‘php://input’);

?>

Meanwhile, if a file is already created with the PUT request, you can go to HTTP status code 201 to update an existing file.

<?php

Header (‘HTTP/1.1 2-1 Created’);

DELETE

DELETE can eliminate the requested URI. It can also return the HTTP/1.1 200 ok.

PHP class

You can use the following steps to implement the WebDAV server.

</php

class Sabre_DAV_Server {

function exec ( ) {

try {

//Invoke the HTTP method

$this – > invoke (strtolower ($_SERVER [‘REQUEST_METHOD’]));

} catch (Sabre_DAV-Exception $e) {

//We caught a DAV exception, so we’ll send back a HTTP status code and re-throw

$this – > sendHTTPStatus ($e->getHTTPCode ( ));

throw $e;

}

}

protected function invoke($method) {

// Make sure this is a HTTP method we support

if (in_array ($method, $this -> getAllowedMethods ( ))) {

$this -> $method ( );

} else {

//Unsupported method

throw new Sabre_DAV_MethodNotImplementedException ( );

}

}

protected function getAllowedMethods ( ) {

return array (‘options’, ‘get’, ‘head’, ‘post’, ‘delete’, ‘trace’, ‘propfind’, ‘proppatch’, ‘copy’, ‘

}

protected function sendHTTPStatus ($code) {

header ($this -> getHTTPStatus( $code) );

}

protected function getHTTPStatus($code) {

$msg = array (

200 => ‘Ok’,

201 => ‘Created’,

204 => ‘No Content’,

207 => ‘Multi-Status’,

403 => ‘Forbidden’,

404 => ‘Not Found’,

409 => ‘Conflict’,

415 => ‘Unsupported Media Type’,

500 => ‘Internal Server Error’,

501 => ‘Method not implemented’,

);

Return ‘HTTP/1.1 ‘    . $code.     ‘ . $msg [$code];

    }

}

?>

Furthermore, you can also run this code to all the exec ( ) method and instantiate the class

<?php

$server = new Sabre_DAV_Server ( );

$server-> exec ( )

?>

Using PHP WebDAV

The following PHP script allows you to use the PHP WebDAV extension:

,? Php

$res = webdav_connect(‘http://webdav.example.com/’, ‘we

bdavuser ‘, ‘webdavpassword’);

webdav_put (‘/setup.txt’, file_get_contents (‘/var/www/se

tup.txt’), $res);

Sa = webdav_get (‘/setup.txt’, $res);

Echo $a;

webdav_unlink( ‘/setup.txt’, $res);

webdav-rename (‘ /setup.txt’, ‘/bla.txt’, TRUE, $res);

webdav-copy(‘ /bla.txt’, ‘ /setup.txt’, TRUE, TRUE, $res;

webdav-unlink (‘setup.txt’, $res);

webdav_close ($res);

?>

php webdav

Your PHP WebDAV Resources and More

Meanwhile, you can also use the README file in PHP WebDAV source. With the use of PHP WebDAV, you can easily access PHP remote resources through the use of DAV protocol. It is based on the Neon reference library.

The PHP WebDAV extension home page is http://[php-webdav.pureftpd.org.

With PHP WebDAV, you can now have unlimited access to your local and remote files. You can edit, delete, or create files and folders for your different projects.