sabredav.php 807 B

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