Building a PHP Front Controller
Subject:   Why use a controller paradigm?
Date:   2004-08-04 14:37:30
From:   thomaskostecki
Response to: Why use a controller paradigm?

There are a few reasons that I've found that make front controllers better than the way you are doing. I'll give you the first two that popped into my head.

One: You gave this example.

$myapp = new MyWebApp();

// program logic

// include page template

// Optional: clean up code

What if this structure needed to change for some reason? Lets say you now need to do
$myapp = new MyWebApp($someParam);
instead of
$myapp = new MyWebApp();
You now need to change this in many places instead of just one!

php paths are based on the file in the url. If you use your example of
then it gets really complicated. The relative paths of all the requires in all the files used in page2.php will need to be different than all the requires for all the files used in page1.php. There are ways around this, but I think it's cleaner to use a controller