Created
January 31, 2020 18:26
-
-
Save mkeneqa/35e7db0a04fb63f36f70646431fa3f1a to your computer and use it in GitHub Desktop.
Symfony PHP, function to get Project Root Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public static function GetProjectRootDir() | |
{ | |
$dirFullPath = __DIR__; | |
//PRE: $dirs = /app/public/src/Helpers | |
$dirs = explode('/',$dirFullPath); | |
array_pop($dirs); //remove last element in array ('Helpers') | |
array_pop($dirs); //remove the next last element from array ('src') | |
//POST: $dirs = /app/public | |
return implode('/',$dirs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment