CodeIgniter Forums

Full Version: Load Libraries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
**New to CI**

I have read the documentation and the Practice CodeIgniter 3.

I can not seem to figure out how to load my own library in 'application/libraries/TestLib'.

Tried :
PHP Code:
$this->load->library('TestLib'); 
and

PHP Code:
$testLib = new App\Libraries\TestLib(); 

I've been looking all over but haven't seemed to figure out why it is not loading.

CodeIgniter-3.1.6
CI will look for the UCfirst name of a libarary, namely "Testlib" in your case.
On Windows, "TestLib" would be found, but not on Linux, because of case sensitivity.
I recommend changing the name to conform to the style guide...
https://www.codeigniter.com/user_guide/g...hod-naming
Ok, so I have refactored the filename to 'Test_lib.php' and class name to Test_lib.

Now what, It's still not found...
(11-03-2017, 04:45 PM)Batman Wrote: [ -> ]Ok, so I have refactored the filename to 'Test_lib.php' and class name to Test_lib.

Now what, It's still not found...

did you set up namespacing in CI3? That sounds like such an obvious question it's almost embarrassing to ask.
I thought I did, but being new to CI, I must admit I may not have it done right. Do you have a resource to point to?
If you set up namespacing you need to use the php use keyword at the top of your class. $this->load will not work.
I thought i did