0

Its similar question of Is there an easy way to get the file where a class was instantiated in PHP? but with different approach.

I need to know the source in autoloading (__autoload() or spl_autoload()) functions so that I can load right class of sub-namespacing

Lets illustrate my problem a little bit by an example - Please consider my following classes: /my/project/root/faculties/faculty.class.php [namespace: faculties] /my/project/root/faculties/faculty1/faculty.class.php [namespace: faculties/faculty1] /my/project/root/faculties/completely/different/project/at/deep/project/root/faculties/faculty.class.php [namespace: faculties]

Now if I want to access instance of that different project its conflict with root project cause its same namespace.

Community
  • 1
  • 1
  • Have you looked at the [PSR 4 FIG definition](http://www.php-fig.org/psr/psr-4/) and it's corresponding [example implementation](http://www.php-fig.org/psr/psr-4/examples/) – Mark Baker Feb 09 '15 at 08:13
  • 1
    As far as I know, it'd would have to be through `debug_backtrace()`. Take a look at http://stackoverflow.com/questions/190421/caller-function-in-php-5 – Dellkan Feb 09 '15 at 08:14
  • @delikan: yes, its an alternative. i don't think this way, thanks – Shahadat Hossain Khan Feb 09 '15 at 08:49

0 Answers0