phpcodeigniterservercodeigniter-3centos7

can't load custom library on Codeigniter 3 on production server


I've look to all existing question about this issue but still couldn't find the answer. I'm working on CentOS 7 Server.

Here is my custom library that I put in application/libraries

Simas_Bridge.php

class Simas_Bridge
{
  private $CI;
  private $client;
  public function __construct()
  {
    $this->CI = &get_instance();
    $this->CI->load->helper(['file']);
    $this->client = new \GuzzleHttp\Client();
  }
  public function get_dokumen_drh($nip = null)
  {
     ///.... Some Code
  }
}

and I call the library from my Controller like this

Form.php

class Form extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->library('simas_bridge');
    }

    public function uploadFile(){
        $this->simas_bridge->get_dokumen_drh('xxxxxxx'); >>>> The Error happens here!!!
    }
}

I've tried to change the way I call the library to $this->load->library('Simas_Bridge') and call the method with $this->Simas_Bridge->get_dokumen_drh(). Try to change the permission to 750 for Simas_Bridge.php file on the server. It still doesn't work. Always get these error

Unable to load the requested class: Simas_Bridge

What could be wrong?


Solution

  • Try to follow naming convention suggested by Codeigniter, in their documentation they suggesting this:

    So based on that what you should do is

    1. rename your file from Simas_Bridge.php to Simasbridge.php
    2. Class declaration change to Class Simasbridge
    3. then call the class by using $this->load->library('simasbridge');

    for more details please refer to this link Codeigniter 3 official documentation