Nitin Kumar Soni
Nitin Kumar Soni

Reputation: 198

Is it possible to find the location of class file by namespace?

I was recently working with pyroCms. It is really a nice CMS. But I seen that a file used php's namespace.

<?php

use Capsule\Schema;

/**
 * Blog module
 *
 * @author  PyroCMS Dev Team
 * @package PyroCMS\Core\Modules\Blog
 */
class Module_Blog extends Module
{
}

So, now i want to find the location of Schema class file. How i can do it? i read the php's class documentation. But didn't get any help.

Does there any other method or trick?

Upvotes: 4

Views: 107

Answers (1)

deceze
deceze

Reputation: 522372

If you have autoloading set up:

$r = new ReflectionClass('Capsule\Schema');
echo $r->getFileName();

Typically though namespace and class names should closely correspond to directory and file names (though they don't have to). A decent editor/IDE should also make a global search easy, worst case a regex search for "class\s+Schema".

Upvotes: 5

Related Questions