Skip to content
PHP Logo

What are the potential pitfalls of using an abstract class like "runner" in PHP for implementing the MVC pattern?

One potential pitfall of using an abstract class like "runner" in PHP for implementing the MVC pattern is that it can lead to tight coupling between the abstract class and its subclasses, making the code harder to maintain and extend. To solve this issue, it is recommended to use interfaces instead of abstract classes for defining common behaviors in the MVC architecture, as interfaces allow for more flexibility and loose coupling between components.

php
interface RunnerInterface {
    public function run();
}

class Model implements RunnerInterface {
    public function run() {
        // Model logic here
    }
}

class View implements RunnerInterface {
    public function run() {
        // View logic here
    }
}

class Controller implements RunnerInterface {
    public function run() {
        // Controller logic here
    }
}