I have a template where I want to generate an anchor to the base URL of my application. In my case the method which handles this is FrontController::index()
.
If it was just a simple link, I can easily do this inside a template:
<?= $this->Html->link('Home', ['controller' => 'Front', 'action' => 'index']); ?>
However, instead of just a simple link with the text "Home" I want to wrap an anchor tag around some other markup. The output I want in plain HTML (not using Cake's helper methods) would be:
<a href="/">
<img class="app-logo" src="/app-logo.png">
<span class="app-name">App name</span>
</a>
I've read How to get the base Url in cakephp? and none of the methods in there work:
echo $this->webroot; // produces 'false'
echo Router::url('/'); // produces 'Class 'App\Controller\Router' not found`
CakePHP 3.5.13