title: PHP, Zend, require_once: "failed to open stream" and "Failed opening required [...]"
body: <p>I'm going nuts!  I've been SO'ing and Googling for 2 hours now.</p>
  
  <p>In short, things were working fine, and then I did some class-restructuring, and now I'm getting this:</p>
  
  <pre><code>    Warning: require_once(Zend/Mail/Transport/Sendmail.php) [function.require-once]: failed to open stream: No such file or directory in /nfs/c09/h02/mnt/136160/domains/xyz.com/html/sandbox/Zend/Mail.php on line 1175
  
      Fatal error: require_once() [function.require]: Failed opening required 'Zend/Mail/Transport/Sendmail.php' (include_path='.:/usr/local/php-5.3.13/share/pear') in /nfs/c09/h02/mnt/136160/domains/xyz.com/html/sandbox/Zend/Mail.php on line 1175
  </code></pre>
  
  <p>I didn't touch how my files were organized:</p>
  
  <pre><code>    sandbox/index.php
      sandbox/settings.php
      sandbox/lib/class1.php
      sandbox/lib/class2.php
      sandbox/lib/class3.php
      sandbox/Zend/...
  </code></pre>
  
  <p>I only changed some class names and their hierarchy.</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php
      require_once 'lib/class1.php';
      $application = new class1();
      $application-&gt;run();
  ?&gt;
  </code></pre>
  
  <p><strong>class1.php</strong></p>
  
  <pre><code>&lt;?php
  
      require_once 'Zend/Loader.php';
      Zend_Loader::loadClass('Zend_Log');
      Zend_Loader::loadClass('Zend_Log_Formatter_Simple');
      Zend_Loader::loadClass('Zend_Log_Writer_Mail');
      Zend_Loader::loadClass('Zend_Log_Writer_Stream');
      Zend_Loader::loadClass('Zend_Mail');
  
      // class definition ...
  ?&gt;
  </code></pre>
  
  <p>None of these <code>require</code>s needed to be touched during my class restructuring.  The specific issue (although I'm sure there is a more general issue) occurs in Zend's <strong>Mail.php</strong>:</p>
  
  <pre><code>/**
   * Sends this email using the given transport or a previously
   * set DefaultTransport or the internal mail function if no
   * default transport had been set.
   *
   * @param  Zend_Mail_Transport_Abstract $transport
   * @return Zend_Mail                    Provides fluent interface
   */
  public function send($transport = null)
  {
      if ($transport === null) {
          if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) {
              require_once 'Zend/Mail/Transport/Sendmail.php';
              $transport = new Zend_Mail_Transport_Sendmail();
          } else {
              $transport = self::$_defaultTransport;
          }
      }
  
      ...
  }
  </code></pre>
  
  <p>(Note how the <code>require</code> is called only on the first attempt to send an email.)</p>
  
  <ol>
  <li><p>Can a new "flow" or order-of-includes possibly cause this issue?  (Since the paths seem okay.  If the paths weren't okay, it'd die at Loader.php, would it not?)</p></li>
  <li><p>Can a circular dependency of some kind cause this issue, before it caused a more "fatal" one?</p></li>
  <li><p>Can a class name possibly conflict with something that already exists?  Previously I had some fairly arcane class names like MalaFwk_Application_Receiver.  Now, names are more generic, e.g. CApplication, CComponent, CDatabase, CLogger, etc.</p></li>
  </ol>
  
  <p>I've tried various things suggested in other SO threads to no avail, but I'm willing to try anything anyone suggests.  I apologize in advance if this isn't a particularly constructive question, but I'm out of ideas, and there were far too many (trivial but widespread) changes to revert and reapply the changes in pieces.  Any help would be greatly appreciated.  (I will be back at ~8:45a EST.)</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>If I add the following line to <strong>index.php</strong>, i.e. "manually" require the file before anything else happens, then things work again.</p>
  
  <pre><code>    require_once 'Zend/Mail/Transport/Sendmail.php';
  </code></pre>
  
  <p>So it appears that, for some reason, by the time the code gets to <code>send()</code>, it can't find the library.  What could possibly cause this?</p>