Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Class 'CI_Myapi' not found in /var/www/castle_invoice_api/sys...
#1

(This post was last modified: 12-22-2015, 03:45 PM by ciadmin.)

<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

(This post was last modified: 12-22-2015, 03:46 PM by ciadmin.)

Remove CI_ suffix.
Keep calm.
Reply
#3

(This post was last modified: 12-22-2015, 03:46 PM by ciadmin.)

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

Remove ` extends REST_Controller` of Myadapter.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB