Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SHMDesign's avatar

the PHP Practitioner: Make a router - How to load static files (js/css) from public folder?

I follow the PHP Practitioner series and I have now a fully functional Router. The only thing I can't get my head around is how to load css files from the public folder.

Every time I try to load it it fails saying something along the lines of (Route not define, GET, css/files.css

Thanks

Eliott

0 likes
1 reply
sylar's avatar
sylar
Best Answer
Level 32
<link rel="stylesheet" type="text/css" href="public/css/style.css">

You can define helper like this

function asset($path)
{
  return CONST_TO_PUBLIC_PATH.'$path';
}

Please or to participate in this conversation.