Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-01-2007, 04:43 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
Default Controller probs since 1.0RC1 upgrade

Since I upgraded from 0.9 to 1.0 I am having uncaught exceptions. Here is my front controller:
Code:
$oFront = Zend_Controller_Front::getInstance();

$oFront->setParam('useDefaultControllerAlways', true);

Zend_Controller_Front::run("/path/to/controllers");
No matter what controller/action I navigate to I get the view rendered properly and then bellow this a "Fatal Error" Uncaught Exception:

File "IndexController.php" was loaded but class "Default_IndexController" was not found in the file

Why is it asking for a class named Default_IndexController? If I comment out the 'useDefaultControllerAlways' then I get:

Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)'

You may ask, why I am using that paramater? It's for 404 handling if a non-existent controller is specified in the URL (I have some code in index/index that redirects)

If I add an error controller (per this thread) to output the exception, I get:
'Zend_View_Exception' with message 'script 'settings/index.phtml' not found in path'

Why is it looking for that? I have a view called "Default.php" there which IS outputting. So why is ZF now looking for another file?

Last edited by djames : 06-01-2007 at 05:03 PM. Reason: Progress
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-01-2007, 06:57 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

This problem was addressed in #zftalk. Apparently Zend released 1.0 quietly with the ViewRenderer helper enabled by default. I really don't think this was a good idea, but nevertheless I've learned to deal with the problem. It looks like all your problems are because of the ViewRender and possibly not using the ErrorHandler plugins correctly. Another thing to consider is the modular directory structure which zend seems to recommend because of the way their code is setup now

The best way is to re-read and understand the controller section of the manual because it has changed alot.
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-01-2007, 08:01 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
Default

Thanks for the reply. Yes, I must read (and hopefully understand) how Zend_Controller works.

My 404 handling goes like this: by using the useDefaultControllerAlways, a bad url goes to index/index. Currently I hold a list of the existing controllers in the session (via scandir). If the incoming controller is not in the list, then I forward to a notFound() action.

I fixed the ViewRenderer problem by putting exit() after render(). I also had to create: class Default_IndexController extends IndexController with the above error handling in order for it to work.

And yes, modular is great, but it will require quite a few changes in my app

Last edited by djames : 06-01-2007 at 08:22 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-01-2007, 08:48 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

:s thats a very "hacky" way of doing it heh. You can disable ViewRenderer using ($front->setParam('noViewRenderer')) or go through the HelperBroker
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-04-2007, 02:55 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
Default

Quote:
Originally Posted by SpotSec View Post
:s thats a very "hacky" way of doing it heh. You can disable ViewRenderer using ($front->setParam('noViewRenderer')) or go through the HelperBroker
So true... very hacky. So I got rid of the hacks! (deleted the Default_Index "class"). Added an ErrorController that handles database/php errors and controller/action errors (with the help of ZF). Per your suggest. I added the param and dropped the exit() in my renderer.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-04-2007, 03:23 PM
Junior Member
 
Join Date: Jun 2007
Posts: 4
Default

Out of curiosity, where do I find the available params for ZF objects?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-05-2007, 10:46 PM
SpotSec's Avatar
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

Zend Framework API Documentation

An ide with code completion always helps though... Looking through the api docs are annoyingly time consuming sometimes.
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 06-07-2007, 11:10 AM
Maugrim The Reaper's Avatar
Junior Member
 
Join Date: Jun 2007
Location: Ireland
Posts: 20
Default

PHP Code:
$oFront->setParam('useDefaultControllerAlways'true); 
From what I remember this starts looking for the Modular form of the default controllers: i.e. Default_IndexController instead of the traditional IndexController classname. Might want to consider disabling this unless it's absolutely needed. For 404 handling there's a new action helper called Zend_Controller_Action_Helper_ErrorHandler. It's enabled by default (just like ViewRenderer) in 1.0.0 RC1. All you need is an ErrorController class with some relevant action methods.

Documentation on it seems scarce - the Migration document notes in just a few lines before tackling the more obvious issues arising from the ViewRenderer.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:29 PM.