Get the path to application folder with ending slash

@param string $append [optional] append anything you want to application path

@return string
@example /var/www/your.site/com/application/
540017
public static function getApplicationPath(string $append = null): string
    {
        if ($append === null) {
            return static::$applicationPath;
        } else {
            return str_replace(DS . DS, DS, static::$applicationPath . $append);
        }
    }
1196619
public function getBaseDirectory($directoryToAppend = null)
    {

        // load the base directory from the system configuration
        $baseDirectory = $this->getSystemConfiguration()->getBaseDirectory();

        // if a directory has been passed, make it absolute and append it
        if ($directoryToAppend != null) {
            $baseDirectory .= $this->makePathAbsolute($directoryToAppend);
        }

        // return the base directory, with the passed path appended
        return $baseDirectory;
    }
1344369
public static function slashPath($path) {
		if (UString::startswith ( $path, "/" ) === false)
			$path = "/" . $path;
		if (! UString::endswith ( $path, "/" ))
			$path = $path . "/";
		return $path;
	}
360473
public function dir(string $type, string $append = ''): string
    {
        return $this->_dir($type, $append);
    }
1127440
public static function getPathFromURL($url)
	{
		$path = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
		$path = str_replace(self::getDomainFromURL($url), '', $path);
		
		if($path == '') return '/';
		
		return $path;
	}
1052126
public function getEtcDir($relativePathToAppend = '')
    {
        return $this->realpath(
            $this->makePathAbsolute(
                $this->getSystemConfiguration()->getParam(DirectoryKeys::ETC) . $this->makePathAbsolute($relativePathToAppend)
            )
        );
    }
320147
private function getApplicationPathFiles(){

		$this->setPathURI(explode('/', preg_replace('/^[\/]*(.*?)[\/]*$/', '\\1', $_SERVER['REQUEST_URI'])));
		$a=$this->getPathURI();


		if($this->getEnvironmentStatus()=='development'){
			$nun_level=explode("/", $this->getAddressUri());

			for ($i=0; $i < count($nun_level)-2; $i++) {
				array_shift($a);
			}
			$this->setPathURI($a);
		}
		foreach ($a as $key => $value) {
			if($this->getNameApplication()==$value){
				unset($a[$key]);
			}
		}

		if(reset($a)=='helpers'){
			array_shift($a);
			$helpers=true;
		}else{
			$helpers=false;
		}
		$this->setPathURI($a);

		foreach ($a as $key => $value) {
			$this->posURL[]=$value;
		}


		$url_array=$this->getPathURI();

		$directory_action=$directory_ctrl=$directory_view='';

		if($helpers==true){

			$directory_action = $this->getPathApplication().'helpers';

			do{
				if( in_array(current($url_array), scandir($directory_action))){
					$directory_action.='/'.current($url_array);
					next($url_array);
					$dir = false;
					if(isset($url_array[key($url_array)+1])){
						$this->setMethodsURI($url_array[key($url_array)+1]);
					}
				}else if( in_array(current($url_array).'.php', scandir($directory_action))){
					$directory_action.='/'.current($url_array).'.php';
					next($url_array);
					$dir = true;
				}else{
					$directory_action.='/index.php';
					$dir = true;
				}
			}while(!$dir);
		}else{
			$directory_ctrl = $this->getPathApplication().'controllers';
			$directory_view = $this->getPathApplication().'views/pages';
			$this->urlCompletePath = substr($this->getPathBaseHref(),0,-1);
			do{
				if( (file_exists($directory_view) && in_array(current($url_array), scandir($directory_view))) || (file_exists($directory_ctrl) && in_array(current($url_array), scandir($directory_ctrl))) ){
					$directory_ctrl.='/'.current($url_array);
					$directory_view.='/'.current($url_array);
					$this->urlCompletePath.='/'.(current($url_array)!='index'?current($url_array):'');
					next($url_array);
					$dir = false;
					if(isset($url_array[key($url_array)])){
						$this->setMethodsURI($url_array[key($url_array)]);
					}
				}else if( (file_exists($directory_view) && in_array(current($url_array).'.php', scandir($directory_view))) || (file_exists($directory_ctrl) && in_array(current($url_array).'.php', scandir($directory_ctrl))) ){
					$directory_ctrl.='/'.current($url_array).'.php';
					$directory_view.='/'.current($url_array).'.php';
					$this->urlCompletePath.='/'.(current($url_array)!='index'?current($url_array):'');
					next($url_array);
					if(isset($url_array[key($url_array)])){
						$this->setMethodsURI($url_array[key($url_array)]);
					}
					$dir = true;
				}else{
					if(isset($url_array[key($url_array)])){
						$this->setMethodsURI($url_array[key($url_array)]);
					}

					if((count($url_array)==0 || is_int(key($url_array)) == false) || (isset($url_array) && $url_array[0]=='')){
						$directory_ctrl.='/index.php';
						$directory_view.='/index.php';
						$this->urlCompletePath.='/';
					}
					$dir = true;
				}

			}while(!$dir);
		}

		//verifica se existe a view
		if($helpers==true && file_exists($directory_action) && is_file($directory_action) ){
			// inicia actoin
			$this->setPageAction($directory_action);
			$this->instanceTemplate($this->getPageAction());
			if (strpos($_SERVER['HTTP_ACCEPT'], 'htm') === false) {
			}else{
				$helpers=false;
				$this->setPageView($this->getPathApplication('views/error/','404.php'));
			}
		}else if((file_exists($directory_ctrl) && is_file($directory_ctrl)) || (file_exists($directory_view) && is_file($directory_view))){
			// inicia controller
			$this->setPageCtrl($directory_ctrl);
			$this->setPageView($directory_view);
		}
		if(!file_exists($directory_ctrl) || !is_file($directory_ctrl)){
			$this->setPageCtrl($this->getPathApplication('controllers/error/','404.php'));
		}
		if(!file_exists($directory_view) || !is_file($directory_view)){
			$this->setPageView($this->getPathApplication('views/error/','404.php'));
		}

		if($helpers==false){
			$this->instanceTemplate($this->getPathApplication('views/layout/','template.php'));
		}

	}
600935
public function getLogDir($relativePathToAppend = '')
    {
        return $this->realpath(
            $this->makePathAbsolute(
                $this->getSystemConfiguration()->getParam(DirectoryKeys::VAR_LOG) . $this->makePathAbsolute($relativePathToAppend)
            )
        );
    }
497510
public static function getCurrentPath()
    {
        if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
            $url = $_SERVER['HTTP_X_REWRITE_URL'];
        } elseif (isset($_SERVER['REQUEST_URI'])) {
            $url = $_SERVER['REQUEST_URI'];
        } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
            $url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
        } else {
            $url = '';
        }

        return strpos($url, '?') ? strstr($url, '?', true) : $url;
    }
795150
public function get_img_url( $path, $default = 'img/no_img.png', $append_version = true ) {
		return empty( $path ) ? '' : $this->get_assets_url( 'img/' . $path, $default, $append_version );
	}
304656
public function GetConfigurationFilePath($fileName) {
        return "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . \Puzzlout\Framework\Helpers\CommonHelper::GetAppName() . '/Config/' . $fileName;
    }
547675
public function getBaseDirectory($directoryToAppend = null)
    {
        $baseDirectory = $this->getNamingDirectory()->search('php:env/baseDirectory');
        if ($directoryToAppend != null) {
            $baseDirectory .= $directoryToAppend;
        }
        return $baseDirectory;
    }
213515
public function getPath()
    {
        $path = !empty($this->info['path']) ? '/'.implode('/', array_map('self::urlEncode', $this->info['path'])).'/' : '/';

        if (isset($this->info['file'])) {
            $path .= self::urlEncode($this->info['file']);

            if (isset($this->info['extension'])) {
                $path .= '.'.$this->info['extension'];
            }
        }

        return $path;
    }
1010430
protected function getFilePath(string $file, ?string $extension = null, ?string $suffix = null): string
	{
		if(strpos($file, '::') === false)
		{
			// No namespace so we'll just use the default path

			$path = $this->path;
		}
		else
		{
			// The file is namespaced so we'll use the namespace path

			[$namespace, $file] = explode('::', $file, 2);

			if(!isset($this->namespaces[$namespace]))
			{
				throw new RuntimeException(vsprintf('The [ %s ] namespace does not exist.', [$namespace]));
			}

			$path = $this->namespaces[$namespace];
		}

		// Append suffix to path if needed

		if($suffix !== null)
		{
			$path .= DIRECTORY_SEPARATOR . $suffix;
		}

		// Return full path to file

		return $path . DIRECTORY_SEPARATOR . str_replace('.', DIRECTORY_SEPARATOR, $file) . ($extension ?? $this->extension);
	}
788882
protected function unitPath($append = null)
    {
        $reflection = new \ReflectionClass($this);
        $realPath = realpath(dirname($reflection->getFileName()) . '/../');

        if (!$append) {
            return $realPath;
        }

        return $realPath . '/' . $append;
    }
498031
private function getPath(string $path) : string
  {
    $path = str_replace('"', "", $path);
    $path = str_replace("'", "", $path);

    $views = self::$views;
    $file = explode('.', $path);

    foreach($file as $name) {
      if (is_dir($views . DIRECTORY_SEPARATOR . $name)) {
        $views = $views . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR;
      }
      else {
        $views = $views . (ends_with($views, '/') ? '' : '.') . $name;
      }
    }

    $parent = substr(self::$views, strrpos(self::$views, DIRECTORY_SEPARATOR) + 1);

    if (str_contains($views, $parent . '.')) {
      $views = str_replace($parent . '.', $parent . DIRECTORY_SEPARATOR, $views);
    }

    return str_replace(self::$views, '', $views);
  }
847798
public function getPathFilename()
    {
        $path = $this->getPath();

        if ($this->isInternal()) {
            return $this->serverRoot.$path;
        }

        $path = $this->documentRoot.$path;

        if (is_dir($path) === true) {
            $path .= '/index.html';
        }

        return preg_replace('/\/\/+/', '/', $path);
    }