Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get file where class has been declared/required from

Tags:

php

how is it possible to get the file and line where a class has been declared from and/or required?

like image 466
clarkk Avatar asked May 02 '11 06:05

clarkk


1 Answers

Use Reflections to figure out where a class was declared:

$reflector = new ReflectionClass('Foobar');
echo $reflector->getFileName();
echo $reflector->getStartLine();

Use inclued to figure out what was included where.

like image 111
deceze Avatar answered Sep 29 '22 12:09

deceze