Welcome Guest, Not a member yet? Register   Sign In
Load Libraries
#1

**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
Reply
#2

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
Reply
#3

Ok, so I have refactored the filename to 'Test_lib.php' and class name to Test_lib.

Now what, It's still not found...
Reply
#4

(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.
Reply
#5

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?
Reply
Reply
#7

If you set up namespacing you need to use the php use keyword at the top of your class. $this->load will not work.
Reply
#8

I thought i did
Reply




Theme © iAndrew 2016 - Forum software by © MyBB