Jump to content
  • Advertisement
Sign in to follow this  
future_man

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

This topic is 1830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!