How can a Dependency Injection Container (DIC) be effectively used in an MVC pattern in PHP?

When using the MVC pattern in PHP, a Dependency Injection Container (DIC) can be effectively used to manage the dependencies between the different components of the application. This helps in decoupling the components and making the code more maintainable and testable.

// Example of using a Dependency Injection Container in an MVC pattern in PHP

// Create the DIC container
$container = new Container();

// Register dependencies
$container->register('Model', function() {
    return new Model();
});

$container->register('View', function() {
    return new View();
});

$container->register('Controller', function() use ($container) {
    return new Controller($container->get('Model'), $container->get('View'));
});

// Resolve dependencies
$controller = $container->get('Controller');

// Use the controller
$controller->handleRequest();