I was wondering if using one script that servers all is a good architecture for a php application? If it is used in a site which grows to have lots of traffic will it still hold up? If not, what are some other suggestions?
this code i think is basically a front controller that calls other controllers depending on what the user sends to the server. $driver is basically the controller for whatever page is to be called.
file: index.php
<?php
if (!in_array ($_GET['page'], array('index', 'contact', 'about')))
{
$page = 'index';
} else {
$page = $_GET['page'];
}
$driver = false;
switch ($page)
{
case 'contact':
include 'classes\contact.php';
$driver = new Contact();
break;
case 'about':
include 'classes\about.php';
$driver = new About()
break;
case 'index':
default:
include 'classes\main.php';
$driver = new Mainpage();
break;
}
if ($driver)
{
$driver->Display();
} else {
die ('some type of 404 message');
}
?>
suggestions, improvements, criticisms are all welcome. i'm trying to build my first OO php websites and would like to know if i'm on the right track. plus i haven't used php in a few years so i might be out of touch with new features and developments.
i have read a few articles that state having a front controller, or one script to server all is bad because that's what apache already does... so this may be bad for performance.