soltice wrote in php

Library Packaging

I've been developing a library to support one of my projects. And although I didn't intend for this library to be distributed, it's gotten so large that I began to think, "Why not?"

But there's a problem. I really don't know how to package library in a way that would be easily installed on a different webserver. Mostly, this has to do with where and how all these different library files refer to one another. Here's an example path:
  • [site root]
    • public_html
      • includes
        • util
        • table
          • sort
            • SortTableByColumn.php
          • join
          • operator
            • AbstractUniaryTableOperator.php
          • iterator
          • error
The file SortTableByColumn.php requires AbstractUniaryTableOperator.php. The problem is, that if I were to include the file by the following line:
require_once("../operator/AbstractUniaryTableOperator.php");
The server dies on execution, claiming it can't find the file. Mind you, it's not SortTableByColumn that's being executed directly, it is being included by another file elsewhere in public_html. According to my understanding of how PHP includes files, the above line should work perfectly fine. Since SortTableByColumn becomes the "current working script", a relative path should work fine, shouldn't it?

Right now I have to use full paths for situations like above. This makes it difficult to transport to another server because my  site root is "/home/deninet/". (I have no option to change this or PHP.ini, since I rent the server.) It's also a bit of an annoyence, since as you can see, the paths can get quite long.

Any suggestions of how to solve the above problem, and how to better package my library for distribution?