Creating a library of classes in php - how to handle the library root location?
Posted
by jax
on Stack Overflow
See other posts from Stack Overflow
or by jax
Published on 2010-06-12T14:25:27Z
Indexed on
2010/06/12
14:33 UTC
Read the original article
Hit count: 184
php
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?
© Stack Overflow or respective owner