I have a DB wrapper class that uses PDO and in the constructor I create a PDO object. The wrapper class is in our namespace and we are using an autoloader. The issue is that the
Normally in our projects we do set include path like this:
set_include_path('PATH_TO_GLOBAL_LIBS; PATH_TO_LIBRARY_1; PATH_TO_LIBRARY_X; PATH_TO_DOCUMENT_ROOT');
By this we tell PHP (Apache) to search these paths for any classes that should be included by autoloader.
Then assuming we have some Library_1
in /var/www/Libs/library_1
and that this path is added to the include_path we could do this:
namespace Company\Common;
Class DB {
private function __construct() {
$this->Handle = new \Library_1();
}
}
which should be the same as
namespace Company\Common;
use \Library_1;
Class DB {
private function __construct() {
$this->Handle = new Library_1();
}
}