What are some best practices for handling object-oriented programming in PHP when using template engines like Smarty?

When using template engines like Smarty in PHP, it is important to separate the presentation logic from the business logic. This can be achieved by creating separate classes for handling business logic and passing the necessary data to the template engine for rendering. By following this approach, the codebase becomes more maintainable and easier to debug.

class User {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

$user = new User('John Doe');
$smarty->assign('user', $user);
$smarty->display('user.tpl');