1<?php
2
3// SabreDAV test server.
4
5class CliLog {
6
7    protected $stream;
8
9    function __construct() {
10
11        $this->stream = fopen('php://stdout','w');
12
13    }
14
15    function log($msg) {
16        fwrite($this->stream, $msg . "\n");
17    }
18
19}
20
21$log = new CliLog();
22
23if (php_sapi_name()!=='cli-server') {
24    die("This script is intended to run on the built-in php webserver");
25}
26
27// Finding composer
28
29
30$paths = array(
31    __DIR__ . '/../vendor/autoload.php',
32    __DIR__ . '/../../../autoload.php',
33);
34
35foreach($paths as $path) {
36    if (file_exists($path)) {
37        include $path;
38        break;
39    }
40}
41
42use Sabre\DAV;
43
44// Root
45$root = new DAV\FS\Directory(getcwd());
46
47// Setting up server.
48$server = new DAV\Server($root);
49
50// Browser plugin
51$server->addPlugin(new DAV\Browser\Plugin());
52
53$server->exec();
54