如果您的服务器上有如下设置:
/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
那么symfony如何知道在哪里找到src文件夹等?
As __DIR__ etc在php中将/path/sites/site2/vendor解析为实际的真实路径…
通过反思!
1. Symfony x
sfProjectConfiguration.class.php
static public function guessRootDir()
{
$r = new ReflectionClass('ProjectConfiguration');
return realpath(dirname($r->getFileName()).'/..');
}
Symfony 2
Symfony内核组件' ' HttpKernel '
public function getRootDir()
{
if (null === $this->rootDir) {
$r = new 'ReflectionObject($this);
$this->rootDir = str_replace('''', '/', dirname($r->getFileName()));
}
return $this->rootDir;
}