如果您的服务器上有设置,例如:
/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文件夹等?
如php中的 __ DIR __ 等会将/ path / sites / site2 / vendor解析为实际的实际路径......
答案 0 :(得分:0)
通过反思!
Symfony 1.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;
}