3 ms·
He didn't elaborate but it's a valid point in the PHP world. Most of the PHP frameworks implement a front controller that all application requests are sent thro
by lftl 16y ago
He didn't elaborate but it's a valid point in the PHP world. Most of the PHP frameworks implement a front controller that all application requests are sent through, but for a lot of applications this isn't necessary in the PHP world. There's no reason not to simply divide your application into separate files and let your webserver call the right file. Particularly interesting is how similar mod_rewrite is to many framework's routes type implementation. You can practically stick the same config in .htaccess and just let Apache handle it.
For a lot of simple applications my "controller" consists of:
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// do my validation and any work needed then the redirect
} else {
// display the resource
}
You might still call that a "controller" but it's pretty different than what most of the frameworks call a controller, and we've pushed the task of routing the request to the right piece of code off to Apache.