function Kernel::getProjectDir
Gets the application root dir (path of the project's composer file).
Overrides KernelInterface::getProjectDir
3 calls to Kernel::getProjectDir()
- Kernel::getCacheDir in vendor/
symfony/ http-kernel/ Kernel.php - Gets the cache directory.
- Kernel::getKernelParameters in vendor/
symfony/ http-kernel/ Kernel.php - Returns the kernel parameters.
- Kernel::getLogDir in vendor/
symfony/ http-kernel/ Kernel.php - Gets the log directory.
File
-
vendor/
symfony/ http-kernel/ Kernel.php, line 247
Class
- Kernel
- The Kernel is the heart of the Symfony system.
Namespace
Symfony\Component\HttpKernelCode
public function getProjectDir() : string {
if (!isset($this->projectDir)) {
$r = new \ReflectionObject($this);
if (!is_file($dir = $r->getFileName())) {
throw new \LogicException(\sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
}
$dir = $rootDir = \dirname($dir);
while (!is_file($dir . '/composer.json')) {
if ($dir === \dirname($dir)) {
return $this->projectDir = $rootDir;
}
$dir = \dirname($dir);
}
$this->projectDir = $dir;
}
return $this->projectDir;
}