What are the advantages and disadvantages of building a custom MVC framework in PHP compared to using an existing framework?

Building a custom MVC framework in PHP allows for complete customization and control over the application structure and functionality. However, it requires more time and effort to develop and maintain compared to using an existing framework like Laravel or Symfony, which provide a wide range of features, libraries, and community support.

// Example of a custom MVC framework in PHP

// Define routes and controllers
$routes = [
    '/' => 'HomeController@index',
    '/about' => 'AboutController@index',
    '/contact' => 'ContactController@index',
];

// Handle incoming requests
$request_uri = $_SERVER['REQUEST_URI'];
if (array_key_exists($request_uri, $routes)) {
    list($controller, $method) = explode('@', $routes[$request_uri]);
    $controller_instance = new $controller();
    $controller_instance->$method();
} else {
    echo '404 Not Found';
}

// Example controller class
class HomeController {
    public function index() {
        echo 'Welcome to the Home Page';
    }
}