Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3214264
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:02:25+00:00 2026-05-17T15:02:25+00:00

I am just getting into OOP and framework design. I have started by using

  • 0

I am just getting into OOP and framework design. I have started by using the following three 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 is the first framework I have tried to work with and because the tutorial is not aimed at complete novices I am finding myself having to reverse-engineer the code to see how everything works. The problem is I’m stuck.

First, I understand the basic concepts of the framework including the directory structure.

Second, I understand what the registry and database class are for (although I don’t fully understand every function within them just yet).

My problem comes with the index.php, template.class.php and page.class.php files. I broadly know what each should do (although further explanation would be nice!) but I do not get how they fit together i.e. how does the index page interact with the template and page objects to actually produce the page that is displayed. I especially cannot work out in what order everything is called.

The index appears to me as:

  • require registry class
  • create instance of registry (don’t quite get this bit – easier way to access database?)
  • store the database and template objects
  • creates new connection from the stored database object
  • choose the skin for the page

Then, and here is where I get lost:

  • build actual page via buildFromTemplates function (which I can’t get my head round)
  • cache a database query
  • assign tab (i’m completely lost as to what a tag is!)
  • set page title
  • display content

Can anyone help break this down for me? I tried Zend before this but it was far too complicated, this one is more accessible but as you can still has me stumped (although I have started to understand objects FAR more by trying).

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:02:25+00:00Added an answer on May 17, 2026 at 3:02 pm

    Firstly I think they over complicated the implementation of the Registry pattern. I always used the following approach which is more straightforward (I’ll print a 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 with the Singleton is just a mess.

    Regarding the aspects where you got lost:

    1. buildFromTemplates
    Method accepts unlimited numbers of parameters func_get_args() as template file locations, either relative or absolute. If relative (as in skins/ not being part of the parameter send) overwrite the variable holding the name $bit with the absolute location. If the file exists read in the variable $content. Repeat until all method arguments are used and add the end result to the Page class.

    2. Query cache
    If the given query does not return a resource_id (which a database query should) it means the query didn’t execute successfully and the method triggers and error. Otherwise save the resource_id in the property queryCache for later use. For example:

    // assume $db is a reference to the database object and that this is the first
    // query
    $db->cacheQuery('SELECT * FROM whatever');
    $results = $db->resultFromCache(0); // previous query resource_id
    

    …. ahhh, forget it.

    This is so messed up, rather recommend you start with some sane framework good for learning internal works. Like CodeIgniter, and move onwards when those concepts are clear.

    This tutorial is full of wrong decisions, like errors instead of exceptions, tight coupling, custom template engine (where plain PHP would have sufficed) and more.

    Even symfony, which is a big framework is not that hard to follow along the lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.