File

PHP File Function

getcwd() - Gets the current working directory

<?php

// current directory
// /home/web/project
echo getcwd() . "\n";

chdir("specific-folder");

// current directory
// /home/web/project/specific-folder
echo getcwd() . "\n";

Get base path from your project

function basePath($path = '') : string {
  $base_path = getcwd();
  $base_path = rtrim($base_path, 'public');
  $base_path = rtrim($base_path, '\/');
  return $base_path . ($path != '' ? DIRECTORY_SEPARATOR . $path : '');
}

Reference