Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ########################### |
| 2 | Using CodeIgniter Libraries |
| 3 | ########################### |
| 4 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 5 | All of the available libraries are located in your *system/libraries/* |
| 6 | directory. In most cases, to use one of these classes involves initializing |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 7 | it within a :doc:`controller <controllers>` using the following |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 8 | initialization method:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 9 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 10 | $this->load->library('class_name'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 11 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 12 | Where 'class_name' is the name of the class you want to invoke. For |
| 13 | example, to load the :doc:`Form Validation Library |
| 14 | <../libraries/form_validation>` you would do this:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 15 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 16 | $this->load->library('form_validation'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 17 | |
| 18 | Once initialized you can use it as indicated in the user guide page |
| 19 | corresponding to that class. |
| 20 | |
| 21 | Additionally, multiple libraries can be loaded at the same time by |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 22 | passing an array of libraries to the load method. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 23 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 24 | Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 25 | |
| 26 | $this->load->library(array('email', 'table')); |
| 27 | |
| 28 | Creating Your Own Libraries |
| 29 | =========================== |
| 30 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 31 | Please read the section of the user guide that discusses how to |
Andrey Andreev | 2029231 | 2013-07-22 14:29:10 +0300 | [diff] [blame] | 32 | :doc:`create your own libraries <creating_libraries>`. |