codeigniter create the new controller with name API


Example

<?php

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

class Api extends CI_Controller {
  //default value
  private $login_credential;

  function __construct() {
    parent::__construct();
    //for user authentication
    $this->load->library('session');

    //set page header type Json as default
    $this->output->set_content_type('application/json');
    //default credentials for user login
    $this->login_credential = array(
        'username'=>'admin',
        'password'=>'test@123',
        'email'=> 'domain@test.com'
      );
  }
}
?>