What is the correct way to access PHP-DI container inside template files?
For instance, if I need to access User class that can output HTML
<div>
<?php $container->get('User')->showCard(); ?>
</div>
Example User class:
<?php
class User {
public function showCard() {
echo "<div>" . $this->name() ."</div>";
}
}
I set global $container
and I can access it in the templates but it feels like the wrong direction because it can also be accessed directly in classes as well