What are the advantages of using a single entry point in PHP for web applications?

When developing web applications in PHP, using a single entry point can help centralize routing logic, improve security by avoiding direct access to individual scripts, and make maintenance and debugging easier by having a single point of entry for all requests.

// index.php

// Include necessary files
require_once 'config.php';
require_once 'functions.php';

// Get the requested URL
$request = $_SERVER['REQUEST_URI'];

// Route the request to the appropriate controller
switch($request) {
    case '/':
        require 'home.php';
        break;
    case '/about':
        require 'about.php';
        break;
    case '/contact':
        require 'contact.php';
        break;
    default:
        http_response_code(404);
        require '404.php';
        break;
}