I am mainly a database person, not framework. I am trying to figure how exactly cake handles the “not showing” of webroot folder. For example I have some images under webroot in a subfolder named upload. And under upload more folders with images. My testsite name is just called cakephp for now, will change later. Now in the browser if I right click image in firefox and view image it shows
http://mysite/cakephp/upload/imgdogs/rover.jpg
But rover.jpg is at public_html\cakephp\webroot\upload\imgdogs\rover.jpg
How is cakephp doing this, (not showing /webroot in url) I am trying to learn how it’s done…
To add I made a constant in paths .php
define('DIR', '/cakephp/');
so in view I can simply
$linev = $linev . '<img src="' . DIR . 'upload/imgdogs/' . $row->dogpic . '" alt="" class="image"></a></td>';
But still doesn’t help explain how cake bypasses showing webroot, thanks
Edit: I noticed that
$linev = '<td class="imgtd"><a href="' . DIR . 'dog/view?dogid=' . $row->dogid . '">';
links to correct results which is
http://localhost/cakephp/dog/view?dogid=216
BUT testing and taking out DIR temp substitute “”
$linev = '<td class="imgtd"><a href="' . "" . 'dog/view?dogid=' . $row->dogid . '">';
Doesn’t work I get this
http://localhost/cakephp/dog/dog/view?dogid=216
dog/ twice. But this
$linev = '<td class="imgtd"><a href="' . "" . 'view?dogid=' . $row->dogid . '">';
works, so here taking DIR out and dog/ automatically knew I needed dog/
You see the confusion, how does cake know I need dog/ added? the route to the view is
$routes->connect('/dog/view/', ['controller' => 'Dogs', 'action' => 'view']);