Download files with WebDAV

I want to download a file with Nextcloud using webDav but it does not work

include '/home/vendor/autoload.php';
function connectDB($userName,$password){
  $settings = array(
    'baseUri' => 'localhost/nextcloud/remote.php/dav/',
    'userName' => $userName,
    'password' => $password
  );
  $client = new Sabre\DAV\Client($settings);
  return $client;
}
$client=connectDB('User','Password');
$response = $client->request("GET", "files/user/Documents/fileexample.jpg");