title: Yii framework not getting functions from library into controller (using class.php files)
body: <p>I am using a Spotify library called MetaTune and was able to do this easily in CodeIgniter but with Yii there have been some teething issues however currently it has started saying:</p>
  
  <pre><code>Fatal error: Call to undefined method stdClass::searchTrack() in ....public_html/Yii/news/protected/controllers/NewsController.php on line 67
  </code></pre>
  
  <p>Howevever, the the function is there. The files in this library all have a <strong>.class.php</strong> suffix (e.g. <strong>MetaTune.class.php</strong>) and the libray files are all stored in:</p>
  
  <pre><code>yii/application/protected/vendors/Metatune
  </code></pre>
  
  <p>With Codeigniter I made an additional spotify.php outside of the folder and autoloaded that to my controller, but im not sure if this is necessary. </p>
  
  <p>I have loaded it in my <strong>config.php</strong> with:</p>
  
  <pre><code>    'import'=&gt;array(
      'application.models.*',
      'application.components.*',
              'application.vendors.metatune.*',
  ),
  </code></pre>
  
  <p>Here is the <strong>Controller</strong> code:</p>
  
  <pre><code>public function actionView($id)
  {
   $model=$this-&gt;loadModel($id);
  
  $spotify = MetaTune::getSomething();
  $hello =  $model-&gt;title;
  Yii::import('application.vendors.metatune.MetaTune');
  $spotify-&gt;autoAddTracksToPlayButton = true; // Will add all searches for tracks into a list.
  $spotify-&gt;playButtonHeight = 330; // For viewing the entire playlist
  $spotify-&gt;playButtonTheme = "dark"; // Changing theme
  $spotify-&gt;playButtonView = "coverart"; // Changing view
  try
  {
      $tracks = $spotify-&gt;searchTrack($hello);
      $tracks = $spotify-&gt;getPlayButtonAutoGenerated($hello);
  }
  catch (MetaTuneException $ex)
  {
      die("&lt;pre&gt;Error\n" . $ex . "&lt;/pre&gt;");
  }
  
  $song = 'tracks';
  
      $this-&gt;render('view',array(
          'model'=&gt;$this-&gt;loadModel($id),
      ));
  }
  </code></pre>
  
  <p>Please also see the code below where it has a function called <strong>getInstance</strong> which doesnt work well with Yii for some reason and Im not sure if I can change this as I used this to import MetaTune into the CodeIgniter controller without any issues. </p>
  
  <p>Just a part of the <strong>MetaTune.class.php</strong> code:
       
  
  <pre><code> Yii::import('application.vendors.metatune.Artist');
   Yii::import('application.vendors.metatune.Album');
   Yii::import('application.vendors.metatune.Track');
   Yii::import('application.vendors.metatune.CacheRequest');
   Yii::import('application.vendors.metatune.MBSimpleXMLElement');
   Yii::import('application.vendors.metatune.SpotifyItem');
   Yii::import('application.vendors.metatune.MetaTuneException');
  
   ....
  
   class MetaTune {
  const CACHE_DIR = 'application/vendors/metatune/cache/'; // Cache directory (must be writable) relative to this file
  const USE_CACHE = false; // Should caching be activated?
  const CACHE_PREFIX = "METATUNE_CACHE_"; // prefix for cache-files. 
  
  const SERVICE_BASE_URL_SEARCH = "http://ws.spotify.com/search/1/";
  const SERVICE_BASE_URL_LOOKUP = "http://ws.spotify.com/lookup/1/";
  const PLAYBUTTON_BASE_URL = "https://embed.spotify.com/?uri=";
  
  public $autoAddTracksToPlayButton = false;
  
  private $list = array();
  
  // Holds instance
  private static $instance;
  
  .....
  
  public static function getSomething()
  {
      if (!isset(self::$instance))
      {
          $class = __CLASS__;
          self::$instance = new $class;
      }
  
      return self::$instance;
  }
  
  .....
  
   public function searchTrack($name, $page = 1)
  {
      $url = self::SERVICE_BASE_URL_SEARCH . "track?q=" . $this-&gt;translateString($name) .  
      $this-&gt;addPageSuffix($page);
      $contents = $this-&gt;requestContent($url);
      $xml = new MBSimpleXMLElement($contents);
  
      $tracks = array();
      foreach ($xml-&gt;track as $track)
      {
          $tracks[] = $this-&gt;extractTrackInfo($track);
      }
  
      if ($this-&gt;autoAddTracksToPlayButton) {
          $this-&gt;appendTracksToTrackList($tracks);
      }
  
      return $tracks;
      } 
  </code></pre>
  
  <p>If you have any suggestions I would be most grateful. Thanks.</p>