title: How to use a PEAR library inside a custom namespace?
body: <p>I can't use a PEAR library when I have my custom namespace declared.</p>
  
  <p>The namespace and the autoload function:</p>
  
  <pre><code>&lt;?php
  namespace ldapwrangler;
  function autoload($class_name)
  {
    $path = ROOT_DIR . "/inc/" . str_replace('\\', "/", $class_name) . ".class.php";    
    require_once($path);
  }
  spl_autoload_register('ldapwrangler\autoload');
  ?&gt;
  </code></pre>
  
  <p>If I try something like this ROOT_DIR/inc/ldapwrangler/LDAP.class.php:</p>
  
  <pre><code>&lt;?php
  namespace ldapwrangler;
  require_once 'Net/LDAP2.php';
  
  class LDAP{
      protected $connection;
      protected $defaultSearchBase;
  
      /**
       * @param $conf conf array containing ldap direction login and server.
       */
      function __construct($conf)
      {
          $this-&gt;connection = $this-&gt;set_connection($conf);
          $this-&gt;defaultSearchBase = $conf['basedn'];
      }
      /**
       * Bind to the directory configured in the $conf array
       * 
       * @param $conf conf array containing ldap direction login and server.
       */ 
      function set_connection($conf)
      {
          $ldap = Net_LDAP2::connect($conf);
  
          // Testing for connection error
          if (PEAR::isError($ldap)) {
              $msg = 'Could not connect to LDAP server: '.$ldap-&gt;getMessage();
              Logging::log_message('error',$msg);
              return false;
          }
          return $ldap;
      }
  
      //rest of the class...
      }
  ?&gt;
  </code></pre>
  
  <p>I get an error like this:</p>
  
  <blockquote>
    <p>May 29 10:03:32 reagand-desktop apache2: PHP Fatal error:  require_once(): Failed opening required '/home/reagand/dev/ldap_wrangler/inc/ldapwrangler/Net_LDAP2.class.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/reagand/dev/ldap_wrangler/config.php on line 18</p>
  </blockquote>
  
  <p>FYI, line 18 is the require_once() part of the autoload function.</p>
  
  <p>How to I tell php to not use the ldapwrangler namespace for the Net_LDAP2 classes? Or any other non-ldapwrangler classes, for that matter.</p>