how to require_once in codeigniter

Ahmed-Anas picture Ahmed-Anas · Jul 31, 2013 · Viewed 66.6k times · Source

I am trying to extend a library in codeigniter. The only way to do so seems to include the original library using require_once then load the extended library using $this->load->library()

right now I have tried

  1. require_once('ion_auth.php');
  2. require_once('home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
  3. require_once('/home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')

but unfortunately not luck..... I keep getting this error

Message: require_once(...) [function.require-once]: failed to open stream: No such file or directory

Weird thing is though this works on my local xampp environment but not on the actual server.

Answer

Use CodeIgniter's built in constant, APPPATH

require_once(APPPATH.'libraries/ion_auth.php');