Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ###################### |
| 2 | Auto-loading Resources |
| 3 | ###################### |
| 4 | |
| 5 | CodeIgniter comes with an "Auto-load" feature that permits libraries, |
| 6 | helpers, and models to be initialized automatically every time the |
| 7 | system runs. If you need certain resources globally throughout your |
| 8 | application you should consider auto-loading them for convenience. |
| 9 | |
| 10 | The following items can be loaded automatically: |
| 11 | |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 12 | - Classes found in the *libraries/* directory |
| 13 | - Helper files found in the *helpers/* directory |
| 14 | - Custom config files found in the *config/* directory |
| 15 | - Language files found in the *system/language/* directory |
| 16 | - Models found in the *models/* folder |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 17 | |
Andrey Andreev | 5a519db | 2013-01-12 04:19:19 +0200 | [diff] [blame] | 18 | To autoload resources, open the **application/config/autoload.php** |
Andrey Andreev | 16a704c | 2012-11-09 17:25:00 +0200 | [diff] [blame] | 19 | file and add the item you want loaded to the autoload array. You'll |
| 20 | find instructions in that file corresponding to each type of item. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 21 | |
| 22 | .. note:: Do not include the file extension (.php) when adding items to |
Andrey Andreev | ed86ee1 | 2014-07-11 19:48:37 +0300 | [diff] [blame] | 23 | the autoload array. |
| 24 | |
| 25 | Additionally, if you want CodeIgniter to use a `Composer <https://getcomposer.org/>`_ |
| 26 | auto-loader, just set ``$config['composer_autoload']`` to ``TRUE`` or |
| 27 | a custom path in **application/config/config.php**. |