Include a module with a ZendFramework library

119 Views Asked by At

I'd like to setup a profiler for my company's ZendFramework and Doctrine installation. Right now I have a bar at the bottom that shows up when on a dev environment that gives some basic timing and query counts (much like the Symfony profiler bar). What I'd like to do, is store all of that information and more in a SQLite database and allow viewing of that information in a profiler like Symfony allows.

Is there a way that allows me to include a module with my company's library where all of the code for this profiler can sit? Ideally, I'd want it setup so that a developer could type in "domainname.com/CompanyProfiler" and it would show them the full screen profiler. It doesn't seem like there currently is a way for me to make that routing possible without a new module.

Edit: After seeing the answer about setControllerDirectory, I looked into the front controller methods and found addModuleDirectory, which sounds like exactly what I need. But I can't get it to work.

$frontController->addModuleDirectory(APPLICATION_PATH . '/../library/Company/modules');

If I do a getControllerDirectory after that, I see:

'profiler' => '{really long correct path}../library/Company/modules\profiler\controllers'

In the "controllers" folder, I have IndexController.php with a class name of:

class Profiler_IndexController extends Zend_Controller_Action

But if I try to go to the URL "/profiler", I get a controller not found error. Any thoughts on what I'm doing wrong?

If I var_dump the errors in my error controller, I can see that it is clearly trying to access the default module.

2

There are 2 best solutions below

0
On BEST ANSWER

Try adding a direct route to the module by placing the following in your bootstrap:

protected function _initRoutes()
{
    $router = Zend_Controller_Front::getInstance()->getRouter();

    // Route for profiler
    $route = new Zend_Controller_Router_Route(
        'profiler/:controller/:action/*',
        array(
            'module'     => 'profiler',
            'controller' => 'index',
            'action'     => 'index'
        )
    );
    $router->addRoute('profiler', $route);
}
0
On

If I understood right, you also want to have the controllers in the library? If so, you can set that ZF looks for CompanyProfiler module where all the controllers are in the library (or anywhere else) using setControllerDirectory().