Women in Technology

Hear us Roar



Article:
  Building a PHP Front Controller
Subject:   Not really seeing the point...
Date:   2004-07-11 15:00:02
From:   ionrock
I am not sure I totally understand the use here. I have made sites using a index page that accepts all the requests but I always find myself feeling as though there are just too many includes and it gets out of control very quickly as options are created. Is this method a solution for this kind of thing?


I have been making an attempt to use a factory method for frontend logic in hopes of reducing the complexity some but it still has felt a bit overwhelming. I could just be thinking that these kinds of things should be avoidable by talented programming when in fact it is inevitable that mundane complexity will come with large projects. In any sense I did enjoy the article and the solution did seem very effective for some cms type uses. Thanks!

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Not really seeing the point...
    2004-07-13 09:02:58  Q Ethan McCallum | O'Reilly AuthorO'Reilly Blogger [View]


    Thanks for the nod.




    As for your situation with "too many includes": you don't say what those includes are, or where they're being made. Any time you can factor out common actions -- such as including the same content in several places -- then it's likely using a front controller would help.

    • Not really seeing the point...
      2004-07-13 11:25:10  ionrock [View]

      The main reason I end using includes is for different actions. The obvious example would be inputting data into a database.

      switch ($_GET['do']) {
      case "forms":
      include "myforms.php";
      break;
      case "db":
      include "handleinfo.php";
      break;
      }

      The issue is that for each and every action we are creating a file. The better solution is of course to make a common means of creating forms and a common means of handling form data using a class. My issue is that while a class to handle all types of data input and a class for creating forms seems to be useful and the most efficient, it also becomes very confusing if you needed to change forms. You edit a large class that might be difficult to understand after a few months or years. On the other hand finding the file with the forms and database input seems very simple. Where then is the advantage in using a class for this kind of action?

      I understand this probably strays a bit from the article regarding patterns and a front controller but I think the root of the article and coding in general lies in creating easy to manage and efficient code. So really, I think the question is really how is the best way to handle a huge tree of options that a web app often takes.

      Your comment does make a lot of sense with regard to producing content to the end user. I think my issues are more associated with creating the admin interface for adding content. That is where things seem to become much more complex (at least in my experience).

      Thanks again for writing the article and if this is not the right forum for my questions/thoughts please don't hesitate to let me know. While I have worked with php for a while I am by no means an expert. I am really trying to learn more about large scale projects that are just too large to be handled using the same concepts as the smaller projects I have worked with in th past.