If you have a setup on your server such as:
/path/sites/site1
app/
bin/
web/
src/
vendor/ -> /path/vendor/Symfony_2.0.3/vendor (symbolic links)
/path/sites/site2
app/
bin/
web/
src/
vendor/ -> /path/vendor/Symfony_2.0.3/vendor (symbolic links)
/path/vendor/Symfony_2.0.3/vendor
How does then symfony know where to find the src folder etc?
As __DIR__ etc in php will resolve the /path/sites/site2/vendor to the actual real path...
Through reflection!
Symfony 1.x
sfProjectConfiguration.class.php
static public function guessRootDir()
{
$r = new ReflectionClass('ProjectConfiguration');
return realpath(dirname($r->getFileName()).'/..');
}
Symfony 2
Symfony\\Component\\HttpKernel\\Kernel
public function getRootDir()
{
if (null === $this->rootDir) {
$r = new \ReflectionObject($this);
$this->rootDir = str_replace('\\', '/', dirname($r->getFileName()));
}
return $this->rootDir;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.