PHP code example of eltharin / webdav

1. Go to this page and download the library: Download eltharin/webdav library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eltharin / webdav example snippets


public function __construct(private KernelInterface $appKernel, private RequestStack $requestStack, BasicAuthManager $authManager)
{
    $this->securityManager = $authManager;
}
 php
    public function getRouteData(): RouteData
    {
        return new RouteData('/webdav');
    }
 php
    public function getRouteData(): RouteData
    {
        return new RouteData('/webdav/{uuid}', ['uuid' => '\d+']);
    }
 php
    public function getFileManager(): FileManagerInterface
    {
        $fileManager = new WebDavFileManager();
        $fileManager->setConfig($this->appKernel->getProjectDir() . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR,
            $this->requestStack->getMainRequest()?->getSchemeAndHttpHost() ?? '' ,
            '/' . $this->getRouteData()->getPath());
        return $fileManager;
    }
 php
use Eltharin\WebdavBundle\FileManager\WebDavFileManager;
use Eltharin\WebdavBundle\Interface\AbstractWebDavConfiguration;
use Eltharin\WebdavBundle\Interface\FileManagerInterface;
use Eltharin\WebdavBundle\Routing\RouteData;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;

class WebDavConfiguration extends AbstractWebDavConfiguration
{
    public function __construct(private KernelInterface $appKernel, private RequestStack $requestStack)
    {
    }
    
    public function getRouteData(): RouteData
    {
        return new RouteData('/webdav');
    }

    public function getFileManager(): FileManagerInterface
    {
        $fileManager = new WebDavFileManager();
        $fileManager->setConfig($this->appKernel->getProjectDir() . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR,
            $this->requestStack->getMainRequest()?->getSchemeAndHttpHost() ?? '' ,
            $this->getRouteData()->getPath()
        );
        return $fileManager;
    }
}