Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's what I did to try and follow your example (from scratch):</p> <pre><code>$ zf create project . $ zf create module product $ zf create module default </code></pre> <p>I then moved <code>controllers</code>, <code>models</code> and <code>views</code> from <code>./application</code> to <code>./application/modules</code>.</p> <p>Next I opened up application.ini, and <strong>replaced</strong> this line (which tells ZF where to find controllers in a non-modular app):</p> <pre><code>resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" </code></pre> <p>with:</p> <pre><code>resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" </code></pre> <p>which tells ZF where to find modules.</p> <p>I then manually created an index controller for the product module so I could test that this worked, which it did. I then hit <a href="http://localhost/index/index" rel="noreferrer">http://localhost/index/index</a> to see if the default module index action still worked, it didn't, instead I got the error:</p> <blockquote> <p>Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller class ("Default_ErrorController")' in ...</p> </blockquote> <p>it sounds like this is where you got to. </p> <p>There are two ways to fix this error, and the documentation is quite misleading (possibly even wrong). It <a href="http://framework.zend.com/manual/en/zend.controller.modular.html" rel="noreferrer">states</a>: </p> <blockquote> <p>Note that in the default module, controllers do not need a namespace prefix. Thus, in the example above, the controllers in the default module do not need a prefix of 'Default_' -- they are simply dispatched according to their base controller name: 'IndexController' and 'FooController'. A namespace prefix is used in all other modules, however. </p> </blockquote> <p>but clearly the error above indicates that ZF is looking for an ErrorController class called Default_ErrorController. To fix this you can do one of two things:</p> <ul> <li>Change the class names of application/modules/default/controllers/IndexController.php from <code>IndexController</code> to <code>Default_IndexController</code>, and application/modules/default/controllers/ErrorController.php from <code>ErrorController</code> to <code>Default_ErrorController</code></li> <li><p>Or remove this line:</p> <p>resources.frontController.params.prefixDefaultModule = "1"</p></li> </ul> <p>from application.ini. This line tells ZF to use the 'Default_' namespace on the default module classes, so without it it will just look for 'IndexController'. I went for the latter option, and <a href="http://localhost/index/index" rel="noreferrer">http://localhost/index/index</a> then worked as expected.</p> <p>In your case you said you got a blank page at /index/index, which means either:</p> <ul> <li>You have a different problem</li> <li>You have errors disabled in development mode</li> <li>You are running in production mode where errors are disabled by default (most likely)</li> </ul> <p>to check the last option, open application.ini and <em>temporarily</em> change <code>phpSettings.display_errors</code> from 0 to 1 in the production section. If you then get the same error I had above, hopefully you'll be able to get everything working.</p> <p>I hope this is helpful. All I can say is don't get too reliant on Zend_Tool for management of your app - it can't do everything, and often it's easier to manually move things around than to try and do everything via. the zf command; particularly when restructuring.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload