Prev | Current Page 38 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

This means that the class definition itself
ensures that there can only be one instance of the object allowed. A Singleton design is appropriate for a front
controller as it ensures that there is only ever one class that is processing the request. One of the consequences
of the Singleton design is that you cannot use the new operator to instantiate it and must, instead, use the
getInstance() static member function. The front controller has a feature that captures all exceptions thrown by
default and stores them into the Response object that it creates. This Response object holds all information
about the response to the requested URL and for HTML applications this is the HTTP headers, the page
content and any exceptions that were thrown. The front controller automatically sends the headers and displays
the page content when it finishes processing the request.
For our Hello World application, I??™ve decided to instruct the front controller to throw all exceptions that
occur (#4). The default behaviour to store exceptions within the response object can be quite confusing for
people new to the Zend Framework, so let??™s turn it off and force the error to be displayed. Of course, on a
production server, you shouldn??™t be displaying errors to the user anyway and so you should either let the
controller catch exceptions or wrap the index.


Pages:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
botox Kraków wyświetlacz xperia Wczasy nad morzem baseny ogrodowe tłumacz niemieckiego