-- Shekar C Reddy <[EMAIL PROTECTED]> wrote
(on Friday, 14 December 2007, 08:43 PM -0600):
> Zend_Controller_Front.php has the following lines of code on the top instead 
> of
> conditionally requiring them in dispatch():
>  
> /** Zend_Controller_Action_Helper_ViewRenderer */
> require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
> 
> /** Zend_Controller_Plugin_ErrorHandler */
> require_once 'Zend/Controller/Plugin/ErrorHandler.php';
>  
>  
> For those who don't use ViewRenderer and ErrorHandler, these files still get
> included on each page-load unless they are moved into dispatch() to require
> them conditionally:
>  
> http://framework.zend.com/issues/browse/ZF-2313

Noted -- thanks for the report. Fixed in SVN.


> On 12/14/07, Matthew Weier O'Phinney <[EMAIL PROTECTED] > wrote:
> 
>     -- Shekar C Reddy < [EMAIL PROTECTED]> wrote
>     (on Friday, 14 December 2007, 12:50 PM -0600):
>     > I would suggest to incorporate a method that serves as a central 
> location
>     to
>     > instantiate exception objects - a consistent object-instantiation 
> system,
>     if
>     > you will. This method could go inside a class that is always required/
>     loaded so
>     > we don't have to include another file just for this purpose. 
> Zend_Loader,
>     > maybe? This approach allows us to add more processing/error-handling
>     logic to
>     > the method in future that ripples across the framework:
>     >
>     > 
> /////////////////////////////////////////////////////////////////////////
>     /
>     > static function getException( $class, $message = 'ERROR', $code = 0, ...
>     )
>     > 
> /////////////////////////////////////////////////////////////////////////
>     /
>     > {
>     >    self::loadClass( $class );
>     >    //
>     >      // Or straight require_once for performance, but then format the
>     > class-name to instantiate...
>     > // require_once( $class );
>     >    //
>     >    return new $class( $message, $code, ... );
>     > }
>     > 
> /////////////////////////////////////////////////////////////////////////
>     //////
>     > /
>     >
>     > Then, from within the code where an exception needs to be thrown, this
>     becomes
>     > just a simple one-liner, instead of spilling require_once/etc lines of
>     code all
>     > over the framework:
>     >
>     > throw Zend_Loader::getException( <class>, <message>, <code>, ... );
> 
>     There are *no* classes right now that get loaded by every other class;
>     doing so introduces unwanted coupling.
> 
>     > 2. On another note, how about other class-files that get included
>     > superfluously? I'm quite sure there are an awful lot of files included
>     > in the framework's classes without ever being used. ViewRenderer.php
>     > is just an example.
> 
>     For what it's worth, the ViewRenderer is loaded during dispatch() only
>     if the user has not set the 'noViewRenderer' flag; same with the
>     ErrorHandler plugin. Users complained about them being loaded, and we
>     listened. :-)
> 
>     > If we really want to reduce the number of included files to improve
>     > performance, we need to work on these ones, too. Bottom line - include
>     > files only on a need-to-use basis and just-in-time! I, for one, don't
>     > want any files loaded that I don't want to use in my application - its
>     > just an over-head.
> 
>     Perhaps you could go and create a list that shows these? I think in most
>     cases, we're not doing includes unless needed... with the exception of
>     exception classes, but we cannot know unless somebody produces an audit.
> 
> 
>     > On 12/13/07, Shahar Evron < [EMAIL PROTECTED] > wrote:
>     >
>     >     A while back ago there was an attempt to eliminate the loading of
>     unused
>     >     Exception files / classes by different ZF components. I don't know
>     what
>     >     happened with that discussion, but I think we should do something
>     about
>     >     it.
>     >
>     >     I've made some profiling of relatively simple ZF-based app (doesn't
>     load
>     >     too many components - mostly the MVC, DB, Config, Registry etc.
>     stuff)
>     >     and I've found some 10 calls to require_once to load an Exception
>     class
>     >     without having a single exception thrown (that I know of - unless
>     some
>     >     ZF code threw an exception and some other ZF component caught it).
>     >
>     >     10 redundant include files have quite an impact on performance,
>     >     especially in places where you have no opcode cache installed.
>     >
>     >     A while back ago I changed Zend_Http_Client to require_once it's
>     >     exception classes only when about to throw an exception, something
>     like:
>     >
>     >     <?php
>     >     if ($error_happened) {
>     >        require_once 'Zend/Http/Client/Exception.php';
>     >        throw new Zend_Http_Client_Exception('Good news, everyone!');
>     >     }
>     >     ?>
>     >
>     >     Now this might seem a bit cumbersome - but when considering the fact
>     >     that it's 1 line of code that never gets executed vs. always loading
>     at
>     >     least one aditional file (not to mention cases where you load
>     >     Zend/Http/Client/Adapter/Exception.php which loads
>     >     Zend/Http/Client/Exception.php which loads Zend/Http/Exception.php
>     which
>     >     loads Zend/Exception.php - you get the point) I think it's worth it.
>     >
>     >     If nobody has a nicer solution to this overweight problem, I suggest
>     all
>     >     component maintainers will start doing the same (this is not my idea
>     and
>     >     I know some already do so).
>     >
>     >     If you want, I can try to come up with a list of places that need to
>     be
>     >     fixed.
>     >
>     >     Better suggestions are most welcome!
>     >
>     >     Thanks,
>     >
>     >     Shahar.
>     >
>     >     --
>     >
>     >     Shahar.
>     >
>     >
>     >
> 
>     --
>     Matthew Weier O'Phinney
>     PHP Developer            | [EMAIL PROTECTED]
>     Zend - The PHP Company   | http://www.zend.com/
> 
> 

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to