php - Help comprehending how the following framework fits together: -


i getting oop , framework design. have started using following 3 tutorials;

http://net.tutsplus.com/tutorials/php/creating-a-php5-framework-part-1/

http://net.tutsplus.com/tutorials/php/create-a-php5-framework-part-2/

http://net.tutsplus.com/tutorials/php/create-a-php5-framework-part-3/

this first framework have tried work , because tutorial not aimed @ complete novices finding myself having reverse-engineer code see how works. problem i'm stuck.

first, understand basic concepts of framework including directory structure.

second, understand registry , database class (although don't understand every function within them yet).

my problem comes index.php, template.class.php , page.class.php files. broadly know each should (although further explanation nice!) not how fit i.e. how index page interact template , page objects produce page displayed. cannot work out in order called.

the index appears me as:

  • require registry class
  • create instance of registry (don't quite bit - easier way access database?)
  • store database , template objects
  • creates new connection stored database object
  • choose skin page

then, , here lost:

  • build actual page via buildfromtemplates function (which can't head round)
  • cache database query
  • assign tab (i'm lost tag is!)
  • set page title
  • display content

can break down me? tried zend before far complicated, 1 more accessible can still has me stumped (although have started understand objects far more trying).

thanks in advance.

firstly think on complicated implementation of registry pattern. used following approach more straightforward (i'll print simplified version of it).

class registry {    protected static $_instances = array();    public static function add($instance, $name) {     self::$_instances[$name] = $instance;   }    public static function get($name) {     return self::$_instances[$name];   } } 

the registry combined singleton mess.

regarding aspects got lost:

1. buildfromtemplates method accepts unlimited numbers of parameters func_get_args() template file locations, either relative or absolute. if relative (as in skins/ not being part of parameter send) overwrite variable holding name $bit absolute location. if file exists read in variable $content. repeat until method arguments used , add end result page class.

2. query cache if given query not return resource_id (which database query should) means query didn't execute , method triggers , error. otherwise save resource_id in property querycache later use. example:

// assume $db reference database object , first // query $db->cachequery('select * whatever'); $results = $db->resultfromcache(0); // previous query resource_id 

.... ahhh, forget it.

this messed up, rather recommend start sane framework learning internal works. codeigniter, , move onwards when concepts clear.

this tutorial full of wrong decisions, errors instead of exceptions, tight coupling, custom template engine (where plain php have sufficed) , more.

even symfony, big framework not hard follow along lines.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -