Re: first php 5 class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 30, 2008 11:13 AM, Nathan Nobbe <quickshiftin@xxxxxxxxx> wrote:
> i dont think Registry::getInstance() is really that much overhead;

In my initial tests I found that static methods accessing $GLOBALS
directly was much faster than using an instance and working on it
tucked away in a static variable.  The getInstance() to pull and check
against the existence of the instance and creating it really added a
lot of extra code execution.

I use the intercept filter pattern on my code execution so that I can
set up different filters for authentication, authorization, gzip
output buffering, session management, etc based on my page needs.  I
then wrap that around a front controller.  So the registry has been
key in being able to push and pull data from many different scopes.
Then again sometimes I just use include files like the php patterns
site recommended[1].

Up until the start of this year my company was stuck in PHP4 since in
the real world clients don't want their sites to break because people
want the latest and greatest.  :)  A big reason I've had to dig around
is because I want to use the best ideas yet be able to run them on 4.
Now that we have 5 running everywhere it might be an option to
re-visit and use a fluent interface to do something like:

registry::getInstance()->get('foo');

I'd store the getInstance() instance in some sort of protected self::
accessed property and return if it exists or not.  Maybe when I get
some free time I'll do a benchmark to see how nasty that is versus
just using static methods.

PDT hasn't ever crashed on me, but now that I've typed that... ;D

[1] http://www.phppatterns.com/docs/design/the_front_controller_and_php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux