bloc07 wrote in php

How do all of you handle paths

I'm starting to run into some issues with using requires and relative paths and I'm curious to know how others handle these issues.

I have some php scripts that create a certain chunk of a website like the nav bar. These scripts will often include other classes like the db class that abstracts the db. Then I will have a php file in the root directory like index.php that will require the navBar.php. The requires in navBar.php use the directory of index.php as the working directory for relative paths. Now I can't use navBar.php from a php file in a directory different than that of index.php.

This seems to make code reuse more complicated than it needs to be. It's not good to use absolute paths, but the way php does relative paths makes it complicated.

How do all of you handle this?