Creating a library of classes in php - how to handle the library root location?
- by jax
I am about to create a collection of classes in php which are interrelated. Now I would like to include files using their absolute path, ie
If I were in
'/com/mysite/licences/Generator.class.php'
I would like to include files like this:
include '/com/mysite/lib/Utils.class.php'
I don't want to include like this, I think it is confusing and ugly
include '../licenses/Utils.class.php'
This works ok, unless 'com' is not in the root of public_html. I assume I will need some sort of prefix to append to each file LIBRARY_ROOT that hold the location of 'com' in the current filesystem. So it might look like this
include LIBRARY_ROOT.'com/mysite/lib/Utils.class.php'
What is the best way to do this?