title: how to create object of class in codeigniter
body: <p>Here is my core php code:</p>
  
  <pre><code>require('common/Client.php');              // include php wrapper  class
  require('common/GrantType/IGrantType.php');// include php wrapper  class//
  require('common/GrantType/AuthorizationCode.php'); // include php wrapper  class//
  const CLIENT_ID     = '***********'; //generated from base_camp api//
  const CLIENT_SECRET ='***********'; 
  const REDIRECT_URI           = '***********';
  const AUTHORIZATION_ENDPOINT = 'https://launchpad.37signals.com/authorization/new';
  const TOKEN_ENDPOINT         = 'https://launchpad.37signals.com/authorization/token';
  
       session_start();
  
  $client = new OAuth2\my_class(CLIENT_ID, CLIENT_SECRET);
  if (!isset($_GET['code']))
   {
     $_SESSION['org'] = $_GET['org'];
    $auth_url = $client-&gt;getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI);
    header('Location: ' . $auth_url);
    die('Redirect');
      }
     else
    {
      $params = array( 'type' =&gt; 'web_server', 'client_id' =&gt; CLIENT_ID, 'redirect_uri' =&gt; REDIRECT_URI, 'client_secret' =&gt; CLIENT_SECRET, 'code' =&gt; $_GET['code']);
   $response = $client-&gt;getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params);
  
  $client-&gt;setAccessToken($response['result']['access_token']);
  
   $org = $_SESSION['org'].'_ess';
   mysql_connect('localhost','root','*******') or die('Cannot connect to database !');
   mysql_select_db($org) or die('No database found in mysql !');
  
  $gcntct = mysql_query("select * from e_users");
  }
  </code></pre>
  
  <p>How do I initialize object of another class in  mvc, I have adopt new method  by initialize new by namespace name and class its show non existing class error.</p>
  
  <pre><code>    oath2 is namespace and client is library class name.
      function a()
      {
  
     $this-&gt;library('client');
  </code></pre>
  
  <p>How do pass <code>clientid</code> and  secret key in during object creation codeigniter as if you    would see my core php code I have initialize object with new operator and pass values , so how could we initialize object of class client and namespace with passing values in constructor.</p>
  
  <pre><code>       } 
       client.php lib
       namesapce oath2
       class client
       {
  
    public function __construct($client_id, $client_secret, $client_auth =          self::AUTH_TYPE_URI, $certificate_file = null)
           {
       if (!extension_loaded('curl')) {
           throw new Exception('The PHP extention curl must be installed to use this library.', Exception::CURL_NOT_FOUND);
        }
  
       $this-&gt;client_id     = $client_id;
       $this-&gt;client_secret = $client_secret;
       $this-&gt;client_auth   = $client_auth;
       $this-&gt;certificate_file = $certificate_file;
       if (!empty($this-&gt;certificate_file)  &amp;&amp; !is_file($this-&gt;certificate_file)) {
          throw new InvalidArgumentException('The certificate file was not found', InvalidArgumentException::CERTIFICATE_NOT_FOUND);
        }
        }
        }
  </code></pre>