Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Front controller for the entire site, or more smaller ones?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 future_man   Members   -  Reputation: 124

Like
0Likes
Like

Posted 13 August 2013 - 11:23 AM

Hey, I was asking a lot of questions lately on this forum and it all boiled down to this one. We all know it is hype to implement front controller or master page index.php that handles all the requests to all the pages and reroutes you etc... All this for cleaner urls, easier code handling...

 

But what if you have a browser game with a lot of locations and variables, states, conditions etc.. I can't write a million if statements or switch statements on my index page. What if I implement such page structure as described below? Basicly you don't have single point of entry or one front controller but more main controllers that connect to subcontrollers:


                                                                  if location forest
                     if loged in                             |---------------------------- forest.php
                  |------------------ start.php -------------|
                  |                                          |    if location home
                  |                                          |-------------------------- homebase.php
                  |                                          |   
                  |                                          |    if location else
index.php---------|                                          |------------------------- anywhere.php
                  |
                  |  if in fight
                  |------------------- combat.php
                  |
                  |  if not loged in
                  |------------------- homepage.php

Why would all pages have to go through index.php? This would be a big mess! Divide pages based on location, for example my start.php page will decide where to redirect further. So in this case I have two bigger controllers not just one front one. Is this still a good convention? I mean is this still a good front controll design or is it better to leave all the redirects to index.php?


Edited by future_man, 13 August 2013 - 11:23 AM.


Sponsor:

#2 Funkomancer   Members   -  Reputation: 152

Like
0Likes
Like

Posted 13 August 2013 - 01:27 PM

I'm a novice at webstuff so please excuse me if I'm way off, but, wouldn't having separate pages for each area just allow the user to skip directly to those areas if they know the URI?

In addition, if you have a check at the start of each area page to redirect them to the appropriate location on each area page so that they can't access an area that isn't their location, wouldn't you have a whole lot of pages to update (and potentially miss/forget to update) if you were to add more areas or remove existing areas?


Dinosaurs Forever!


#3 future_man   Members   -  Reputation: 124

Like
0Likes
Like

Posted 13 August 2013 - 01:52 PM

I'm a novice at webstuff so please excuse me if I'm way off, but, wouldn't having separate pages for each area just allow the user to skip directly to those areas if they know the URI?

In addition, if you have a check at the start of each area page to redirect them to the appropriate location on each area page so that they can't access an area that isn't their location, wouldn't you have a whole lot of pages to update (and potentially miss/forget to update) if you were to add more areas or remove existing areas?

 

Yes you are right, however I am also aware of this form of "cheating" this is why I simply solved the problem with database entry. You see every location updates the users "location" in the database and a simple function to call that "location" is in order for every new choice user makes to travel. If I am to create a new location I will simply include that function on my new location php page controller. Also I intend to hide full URLs via .htaccess but that is simply for nicer UI.


Edited by future_man, 13 August 2013 - 01:53 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS