title: How come my code works separately but not when I merge it with my controller?
body: <p>I wrote this code in a <code>test.php</code> file.</p>
  
  <pre><code>&lt;?php 
  
  include ($_SERVER["DOCUMENT_ROOT"].'/MySite/protected/MyYouTube/google/src/Google/autoload.php'); 
  
  require_once ($_SERVER["DOCUMENT_ROOT"].'/MySite/protected/MyYouTube/google/src/Google/Client.php');  
  require_once ($_SERVER["DOCUMENT_ROOT"].'/MySite/protected/MyYouTube/google/src/Google/Service/YouTube.php'); 
  ?&gt;
  </code></pre>
  
  <p>If I go to this file like this: <code>localhost/MySite/protected/MyYouTube/test.php</code> it works, but if I copy the same code into my controller that is located under the same folder as <code>test.php</code>, I get this:</p>
  
  <blockquote>
    <p>include(Google_Service.php): failed to open stream: No such file or
    directory</p>
  </blockquote>
  
  <p>There are no conflicts with the imports. In fact, the controller and view can be empty and still I get the same thing.</p>
  
  <p>Apparently that happens when <code>autoload.php</code> is not actually loaded. </p>
  
  <p>How is it possible that when the code is integrated into the website it throws this error? </p>
  
  <p>This is what the path to my site looks like:
        <code>localhost/MySite/index.php/user/view</code> <strong>It seems that the way I visit the file matters.</strong></p>
  
  <hr>
  
  <p>I tried several things. I tried importing the <code>test.php</code> into my view or my controller, and still I get the same error. I tried using <code>Yii::app()-&gt;basePath</code> and it gives the same problem.</p>
  
  <p>The paths are correct, I have checked several times. How can I fix this?</p>