• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fatal error: Class 'CI_Myapi' not found in /var/www/castle_invoice_api/sys...

#1
<b>Fatal error</b>:  Class 'CI_Myapi' not found in <b>/var/www/castle_invoice_api/system/core/Common.php</b> on line <b>196</b><br />

I have got this error.Please tell me how to resolve this.My code is

application/config/autoload.php

$autoload['libraries'] = array('Myapi');


application/controllers/Main.php

defined('BASEPATH') OR exit('No direct script access allowed');

require APPPATH . '/libraries/REST_Controller.php';

interface MyInterface {

public function disp();

}

class Myadapter extends REST_Controller implements MyInterface {

public function __construct()
{
// Construct the parent class
parent::__construct();
}

public function disp()
{
        return 'sample msg';
}
}

class Main extends REST_Controller {
public $client = FALSE;
public function __construct()
{
// Construct the parent class
parent::__construct();

$this->__authenticate();
}

public function index_post()
{
$resp = new stdClass();
    $resp->status = false;
    $resp->message = 'something went wrong';

$api = $this->Gateway('api1');

$resp->message = $api->disp();
$this->response($resp, 400);
}
private function __authenticate()
{
        $this->client = $this->myapi->__authenticate();
}

private function Gateway($type='')
{
        switch($type) {
      case "api1":
        $api = new Myadapter();
        return $api;
        break;
      case "api2":
        $api = new Myadapter1();
        return $api;
      break;
      default:
        // Do something to log an exception
        return false;
        break;
   }
}
}
Reply

#2
Remove CI_ suffix.
Keep calm.
Reply

#3
Because Myadapter is a controller.
You can't instantiate controllers in CI.

Remove ` extends REST_Controller` of Myadapter.
Do you want to write tests for your apps? Our book, CodeIgniter Testing Guide would help you.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.