myPath = $myPath; } function getChildren() { $children = array(); // Loop through the directory, and create objects for each node foreach(scandir($this->myPath) as $node) { // Ignoring files staring with . if ($node[0]==='.') continue; $children[] = $this->getChild($node); } return $children; } function getChild($name) { $path = $this->myPath . '/' . $name; // We have to throw a NotFound exception if the file didn't exist if (!file_exists($this->myPath)) throw new Sabre_DAV_Exception_NotFound('The file with name: ' . $name . ' could not be found'); // Some added security if ($name[0]=='.') throw new Sabre_DAV_Exception_NotFound('Access denied'); if (is_dir($path)) { return new MyDirectory($name); } else { return new MyFile($path); } } function getName() { return basename($this->myPath); } } class MyFile extends Sabre_DAV_File { private $myPath; function __construct($myPath) { $this->myPath = $myPath; } function getName() { return basename($this->myPath); } function get() { return fopen($this->myPath,'r'); } function getSize() { return filesize($this->myPath); } } // Make sure there is a directory in your current directory named 'public'. We will be exposing that directory to WebDAV $rootNode = new MyDirectory($publicDir); // The rootNode needs to be passed to the server object. $server = new Sabre_DAV_Server($rootNode); // And off we go! $server->exec();