title: How to import a class in a controller of CakePHP 2.0?
body: <p>I am using CakePHP. I created an external class which is not a model nor a controller. The structure of the class looks like this</p>
  
  <pre>
  class UploadImage{
      function sayHello(){
         return "hahaha";
     }
  }
  </pre>
  
  <p>I saved the class in the App->Lib directory and named it as UploadImage.php</p>
  
  <p>I wanted to call the method <code>sayHello()</code> in my controller which is:</p>
  
  <pre>
  class ContentsController extends AppController {
  
      public $helpers = array('Html', 'Form');
  
      public function index() {
          $test = App::uses('UploadImage','Lib');
          debug($test->sayHello());
      }
  }
  </pre>
  
  <p>Now when I run the above page, I get the following error:</p>
  
  <blockquote>
    <p>Error: Call to a member function sayHello() on a non-object</p>
  </blockquote>