-- Brooks, Rob A <[email protected]> wrote
(on Saturday, 09 May 2009, 01:25 PM -0500):
> Hello, I’m trying to use php reflection to inspect some of my controller
> classes
>
> If I try the following with any class in the distro it works fine
>
> $class = new ReflectionClass(<distro class>);
>
> I have a ‘library’ folder at the root level of my application and I can
> reflect
> classes in there as well. ( the library path is set in ‘set_include_path’ in
> index.php)
>
> However when I try to reflect a class in one of my module’s controllers, then
> no go
>
> Here is my layout
>
> modules/admin/controller/AuthController.php
>
> The class is named ‘Admin_Controller_Auth’
It *should* be named Admin_AuthController if you want it to work with
the defaults in Zend_Controller. That's your first problem.
> The ‘modules’ directory is included with set_include_path in my index.php file
>
> When I try $class= new ReflectionClass('Admin_Controller_Auth'); in my
> bootstrap file
>
> It throws an exception and says ‘Class Admin_Controller_Auth does not exist’
This is because the file is not loaded yet -- and cannot be loaded via
autoloading.
The dispatcher performs some logic to do a lookup from the class name to
the filesystem -- it doesn't use autoloading. As such, if you want to do
reflection on a controller, you'll need to either ensure it's already
been loaded by the dispatcher, or do a require_once yourself, manually
resolving the class's filename.
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/