blob: 9bbda51bb692678a53bd54989a63149ace133ecf [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001###########################
2Using CodeIgniter Libraries
3###########################
4
Andrey Andreev16a704c2012-11-09 17:25:00 +02005All of the available libraries are located in your *system/libraries/*
6directory. In most cases, to use one of these classes involves initializing
Derek Jones8ede1a22011-10-05 13:34:52 -05007it within a :doc:`controller <controllers>` using the following
Andrey Andreev16a704c2012-11-09 17:25:00 +02008initialization method::
Derek Jones8ede1a22011-10-05 13:34:52 -05009
Andrey Andreev16a704c2012-11-09 17:25:00 +020010 $this->load->library('class_name');
Derek Jones8ede1a22011-10-05 13:34:52 -050011
Andrey Andreev16a704c2012-11-09 17:25:00 +020012Where 'class_name' is the name of the class you want to invoke. For
13example, to load the :doc:`Form Validation Library
14<../libraries/form_validation>` you would do this::
Derek Jones8ede1a22011-10-05 13:34:52 -050015
Andrey Andreev16a704c2012-11-09 17:25:00 +020016 $this->load->library('form_validation');
Derek Jones8ede1a22011-10-05 13:34:52 -050017
18Once initialized you can use it as indicated in the user guide page
19corresponding to that class.
20
21Additionally, multiple libraries can be loaded at the same time by
Andrey Andreev16a704c2012-11-09 17:25:00 +020022passing an array of libraries to the load method.
Derek Jones8ede1a22011-10-05 13:34:52 -050023
Andrey Andreev16a704c2012-11-09 17:25:00 +020024Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050025
26 $this->load->library(array('email', 'table'));
27
28Creating Your Own Libraries
29===========================
30
Andrey Andreev16a704c2012-11-09 17:25:00 +020031Please read the section of the user guide that discusses how to
Andrey Andreev20292312013-07-22 14:29:10 +030032:doc:`create your own libraries <creating_libraries>`.