JBZoo\Utils\Sys::getDocRoot PHP Метод

getDocRoot() публичный статический Метод

Return document root
public static getDocRoot ( ) : string
Результат string
    public static function getDocRoot()
    {
        $result = '.';
        $root = Arr::key('DOCUMENT_ROOT', $_SERVER, true);
        if ($root) {
            $result = $root;
        }
        $result = FS::clean($result);
        $result = FS::real($result);
        if (!$result) {
            $result = FS::real('.');
            // @codeCoverageIgnore
        }
        return $result;
    }

Usage Example

Пример #1
0
 /**
  * @param array $options
  * @return Data
  * @throws Exception
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 protected function _prepareOptions(array $options)
 {
     // Default data for current system
     $this->_default['root_url'] = Url::root();
     $this->_default['root_path'] = Sys::getDocRoot();
     $options = array_merge($this->_default, $options);
     // Check cache directory
     $cachePath = FS::clean($options['cache_path']);
     if (!$cachePath) {
         throw new Exception('Option "cache_path" is empty!');
     }
     if (!FS::isDir($cachePath)) {
         mkdir($cachePath, 0755, true);
     }
     $options['cache_path'] = FS::real($cachePath);
     $options['root_url'] = rtrim($options['root_url'], '/');
     $options['root_path'] = FS::real($options['root_path']);
     $options['driver'] = ucfirst(strtolower(trim($options['driver'])));
     // Check mixin paths
     $lessFile = (array) $options['autoload'];
     foreach ($lessFile as $key => $mixin) {
         $lessFile[$key] = FS::real($mixin);
     }
     $options['autoload'] = array_filter($lessFile);
     // Check imported paths
     $importPaths = [];
     foreach ((array) $options['import_paths'] as $path => $uri) {
         if ($cleanPath = FS::real($path)) {
             $importPaths[$cleanPath] = $uri;
         }
     }
     $importPaths[$options['root_path']] = $options['root_url'];
     // Forced add root path in the end of list!
     $options['import_paths'] = array_filter($importPaths);
     return new Data($options);
 }
All Usage Examples Of JBZoo\Utils\Sys::getDocRoot