Last Updated: February 25, 2016
· rezigned

Be careful with require_once


You encounter this kind of error "Cannot redeclare class ..." even though you already used the require_once to make sure that you include the file only once. What!?


The problem is, there's a chance that the path that being included has different character cases from the physical file on the system. (Due to case sensitivity)

For example (The actual file is 'App/File.php')

 require_once 'App/file.php';

 # if you somehow run this require_once again. It will shows the error above
 require_once 'App/file.php'

So, make sure you have the correct file name before execute the require_once