Recently I’ve been using Codeigniter, and here’s how to use or create CI library.
How to use it
CI default libraries are located in system/libraries
, and in order to use it, you just need to initialize it and use it.
|
|
Different library has different way to use it, so you need to check the documentation for each library.
How to create it
You can also create a library. According to CI documentation, we can do three things.
- Create new library.
- Extend native library.
- Replace native library.
note* database class cannot be extended or replaced.
Keep three rules
- Capitalize first letter for file names.
- Capitalize first letter of class name.
- Class name must match the file name.
After you create your library class, you can use it like when you are using native library.
But if you want to pass parameters when you initialize your class, you must make your constructor accept parameters.
|
|
Extending or utilizing CI resources in your library will be discussed in another time.