Platformsh\Cli\Local\LocalApplication::getDocumentRoot PHP Method

getDocumentRoot() public method

Get the configured document root for the application, as a relative path.
public getDocumentRoot ( ) : string
return string
    public function getDocumentRoot()
    {
        $config = $this->getConfig();
        // The default document root is '/public'. This is used if the root is
        // not set, if it is empty, or if it is set to '/'.
        $documentRoot = '/public';
        if (!empty($config['web']['locations']['/']['root']) && $config['web']['locations']['/']['root'] !== '/') {
            $documentRoot = $config['web']['locations']['/']['root'];
        }
        return ltrim($documentRoot, '/');
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function prepare($buildDir, LocalApplication $app, CliConfig $config, array $settings = [])
 {
     $this->app = $app;
     $this->appRoot = $app->getRoot();
     $this->documentRoot = $app->getDocumentRoot();
     $this->settings = $settings;
     $this->config = $config;
     if ($this->config->get('local.copy_on_windows')) {
         $this->fsHelper->setCopyOnWindows(true);
     }
     $this->ignoredFiles[] = $this->config->get('local.web_root');
     $this->setBuildDir($buildDir);
     if (!empty($settings['clone'])) {
         $settings['copy'] = true;
     }
     $this->copy = !empty($settings['copy']);
     $this->fsHelper->setRelativeLinks(empty($settings['abslinks']));
 }
All Usage Examples Of Platformsh\Cli\Local\LocalApplication::getDocumentRoot