Why absolute path constants __DIR__ and __FILE__ should not be used in Symfony
问题 I use SensioLabs Insight to control my code quality. For a simple file upload, I have to get the absolute path of my uploads directory: protected function getUploadRootDir() { // the absolute directory path where uploaded return __DIR__.'/../../../../web/'.$this->getUploadDir(); } Code directly coming from official documentation (How to handle file uploads with Doctrine) But SLInsight raises a warning if the code analysed contains __DIR__ or __FILE__ PHP magic constants: __DIR__ and __FILE__