sabredav.php 818 B

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