admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
Derek Allard | afd99ac | 2008-01-19 19:59:14 +0000 | [diff] [blame] | 2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 3 | <head>
|
| 4 |
|
Derek Jones | fd93d22 | 2008-05-06 15:18:50 +0000 | [diff] [blame^] | 5 | <title>Creating Libraries : CodeIgniter User Guide</title>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 6 |
|
| 7 | <style type='text/css' media='all'>@import url('../userguide.css');</style>
|
| 8 | <link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
| 9 |
|
admin | 17a890d | 2006-09-27 20:42:42 +0000 | [diff] [blame] | 10 | <script type="text/javascript" src="../nav/nav.js"></script>
|
admin | 2296fc3 | 2006-09-27 21:07:02 +0000 | [diff] [blame] | 11 | <script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
admin | 17a890d | 2006-09-27 20:42:42 +0000 | [diff] [blame] | 12 | <script type="text/javascript" src="../nav/moo.fx.js"></script>
|
Derek Allard | b341237 | 2007-10-25 12:15:16 +0000 | [diff] [blame] | 13 | <script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 14 |
|
| 15 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
| 16 | <meta http-equiv='expires' content='-1' />
|
| 17 | <meta http-equiv= 'pragma' content='no-cache' />
|
| 18 | <meta name='robots' content='all' />
|
Derek Allard | 3d879d5 | 2008-01-18 19:41:32 +0000 | [diff] [blame] | 19 | <meta name='author' content='ExpressionEngine Dev Team' />
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 20 | <meta name='description' content='CodeIgniter User Guide' />
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 21 |
|
| 22 | </head>
|
| 23 | <body>
|
| 24 |
|
| 25 | <!-- START NAVIGATION -->
|
| 26 | <div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
| 27 | <div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
| 28 | <div id="masthead">
|
| 29 | <table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
| 30 | <tr>
|
Derek Allard | 197d10b | 2008-02-12 04:20:38 +0000 | [diff] [blame] | 31 | <td><h1>CodeIgniter User Guide Version 1.6.1</h1></td>
|
admin | c0d5d52 | 2006-10-30 19:40:35 +0000 | [diff] [blame] | 32 | <td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 33 | </tr>
|
| 34 | </table>
|
| 35 | </div>
|
| 36 | <!-- END NAVIGATION -->
|
| 37 |
|
| 38 |
|
| 39 | <!-- START BREADCRUMB -->
|
| 40 | <table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
| 41 | <tr>
|
| 42 | <td id="breadcrumb">
|
Derek Jones | 7a9193a | 2008-01-21 18:39:20 +0000 | [diff] [blame] | 43 | <a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 44 | <a href="../index.html">User Guide Home</a> ›
|
| 45 | Creating Libraries
|
| 46 | </td>
|
Derek Allard | bc03091 | 2007-06-24 18:25:29 +0000 | [diff] [blame] | 47 | <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 48 | </tr>
|
| 49 | </table>
|
| 50 | <!-- END BREADCRUMB -->
|
| 51 |
|
| 52 | <br clear="all" />
|
| 53 |
|
| 54 |
|
| 55 | <!-- START CONTENT -->
|
| 56 | <div id="content">
|
| 57 |
|
| 58 | <h1>Creating Libraries</h1>
|
| 59 |
|
| 60 | <p>When we use the term "Libraries" we are normally referring to the classes that are located in the <kbd>libraries</kbd>
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 61 | directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create
|
| 62 | your own libraries within your <dfn>application/libraries</dfn> directory in order to maintain separation between your local resources
|
admin | 33de9a1 | 2006-09-28 06:50:16 +0000 | [diff] [blame] | 63 | and the global framework resources.</p>
|
| 64 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 65 | <p>As an added bonus, CodeIgniter permits your libraries to <kbd>extend</kbd> native classes if you simply need to add some functionality
|
Derek Allard | c644128 | 2007-07-04 23:54:32 +0000 | [diff] [blame] | 66 | to an existing library. Or you can even replace native libraries just by placing identically named versions in your <dfn>application/libraries</dfn> folder.</p>
|
admin | 33de9a1 | 2006-09-28 06:50:16 +0000 | [diff] [blame] | 67 |
|
| 68 | <p>In summary:</p>
|
| 69 |
|
| 70 | <ul>
|
| 71 | <li>You can create entirely new libraries.</li>
|
| 72 | <li>You can extend native libraries.</li>
|
| 73 | <li>You can replace native libraries.</li>
|
| 74 | </ul>
|
| 75 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 76 | <p>The page below explains these three concepts in detail.</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 77 |
|
admin | 79c643d | 2006-09-28 07:26:21 +0000 | [diff] [blame] | 78 | <p class="important"><strong>Note:</strong> The Database classes can not be extended or replaced with your own classes,
|
Derek Jones | 2e44e0b | 2008-02-13 03:59:34 +0000 | [diff] [blame] | 79 | nor can the Loader class in PHP 4. All other classes are able to be replaced/extended.</p>
|
admin | 79c643d | 2006-09-28 07:26:21 +0000 | [diff] [blame] | 80 |
|
| 81 |
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 82 | <h2>Storage</h2>
|
| 83 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 84 | <p>Your library classes should be placed within your <dfn>application/libraries</dfn> folder, as this is where CodeIgniter will look for them when
|
admin | 33de9a1 | 2006-09-28 06:50:16 +0000 | [diff] [blame] | 85 | they are initialized.</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 86 |
|
| 87 |
|
| 88 | <h2>Naming Conventions</h2>
|
| 89 |
|
| 90 | <ul>
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 91 | <li>File names must be capitalized. For example: <dfn>Myclass.php</dfn></li>
|
| 92 | <li>Class declarations must be capitalized. For example: <kbd>class Myclass</kbd></li>
|
| 93 | <li>Class names and file names must match.</li>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 94 | </ul>
|
| 95 |
|
| 96 |
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 97 | <h2>The Class File</h2>
|
| 98 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 99 | <p>Classes should have this basic prototype (Note: We are using the name <kbd>Someclass</kbd> purely as an example):</p>
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 100 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 101 | <code><?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 102 | <br /><br />
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 103 | class Someclass {<br />
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 104 | <br />
|
| 105 | function some_function()<br />
|
| 106 | {<br />
|
| 107 | }<br />
|
| 108 | }<br /><br />
|
| 109 | ?></code>
|
| 110 |
|
| 111 |
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 112 | <h2>Using Your Class</h2>
|
| 113 |
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 114 | <p>From within any of your <a href="controllers.html">Controller</a> functions you can initialize your class using the standard:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 115 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 116 | <code>$this->load->library('<kbd>someclass</kbd>');</code>
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 117 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 118 | <p>Where <em>someclass</em> is the file name, without the ".php" file extension. You can submit the file name capitalized or lower case.
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 119 | CodeIgniter doesn't care.</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 120 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 121 | <p>Once loaded you can access your class using the <kbd>lower case</kbd> version:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 122 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 123 | <code>$this-><kbd>someclass</kbd>->some_function(); // Object instances will always be lower case
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 124 | </code>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 125 |
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 126 |
|
| 127 |
|
| 128 | <h2>Passing Parameters When Initializing Your Class</h2>
|
| 129 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 130 | <p>In the library loading function you can dynamically pass data via the second parameter and it will be passed to your class
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 131 | constructor:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 132 |
|
| 133 | <code>
|
| 134 | $params = array('type' => 'large', 'color' => 'red');<br />
|
| 135 | <br />
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 136 | $this->load->library('Someclass', <kbd>$params</kbd>);</code>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 137 |
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 138 | <p>If you use this feature you must set up your class constructor to expect data:</p>
|
| 139 |
|
| 140 | <code><?php if (!defined('BASEPATH')) exit('No direct script access allowed');<br />
|
| 141 | <br />
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 142 | class Someclass {<br />
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 143 | <br />
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 144 | function Someclass($params)<br />
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 145 | {<br />
|
| 146 | // Do something with $params<br />
|
| 147 | }<br />
|
| 148 | }<br /><br />
|
| 149 | ?></code>
|
| 150 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 151 | <p class="important">You can also pass parameters stored in a config file. Simply create a config file named identically to the class <kbd>file name</kbd>
|
| 152 | and store it in your <dfn>application/config/</dfn> folder. Note that if you dynamically pass parameters as described above,
|
| 153 | the config file option will not be available.</p>
|
admin | ebbe383 | 2006-09-26 06:02:47 +0000 | [diff] [blame] | 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 159 |
|
| 160 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 161 | <h2>Utilizing CodeIgniter Resources within Your Library</h2>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 162 |
|
| 163 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 164 | <p>To access CodeIgniter's native resources within your library use the <kbd>get_instance()</kbd> function.
|
| 165 | This function returns the CodeIgniter super object.</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 166 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 167 | <p>Normally from within your controller functions you will call any of the available CodeIgniter functions using the <kbd>$this</kbd> construct:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 168 |
|
| 169 | <code>
|
| 170 | <strong>$this</strong>->load->helper('url');<br />
|
| 171 | <strong>$this</strong>->load->library('session');<br />
|
| 172 | <strong>$this</strong>->config->item('base_url');<br />
|
| 173 | etc.
|
| 174 | </code>
|
| 175 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 176 | <p><kbd>$this</kbd>, however, only works directly within your controllers, your models, or your views.
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 177 | If you would like to use CodeIgniter's classes from within your own custom classes you can do so as follows:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 178 |
|
| 179 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 180 | <p>First, assign the CodeIgniter object to a variable:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 181 |
|
Derek Allard | ce66d15 | 2008-03-04 20:55:55 +0000 | [diff] [blame] | 182 | <code>$CI =& get_instance();</code>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 183 |
|
| 184 | <p>Once you've assigned the object to a variable, you'll use that variable <em>instead</em> of <kbd>$this</kbd>:</p>
|
| 185 |
|
| 186 | <code>
|
Derek Allard | ce66d15 | 2008-03-04 20:55:55 +0000 | [diff] [blame] | 187 | $CI =& get_instance();<br />
|
| 188 | <br />
|
admin | 88a8ad1 | 2006-10-07 03:16:32 +0000 | [diff] [blame] | 189 | $CI->load->helper('url');<br />
|
| 190 | $CI->load->library('session');<br />
|
| 191 | $CI->config->item('base_url');<br />
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 192 | etc.
|
| 193 | </code>
|
| 194 |
|
| 195 | <p class="important"><strong>Note:</strong> You'll notice that the above get_instance() function is being passed by reference:
|
| 196 | <br /><br />
|
Derek Allard | ce66d15 | 2008-03-04 20:55:55 +0000 | [diff] [blame] | 197 | <var>$CI =& get_instance();</var>
|
| 198 | <br />
|
| 199 | <br />
|
Rick Ellis | 1f85263 | 2007-06-09 00:25:57 +0000 | [diff] [blame] | 200 | <kbd>This is very important.</kbd> Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it.
|
| 201 | <br /><br />
|
| 202 | <kbd>Also, please note:</kbd> If you are running PHP 4 it's usually best to avoid calling <dfn>get_instance()</dfn>
|
| 203 | from within your class constructors. PHP 4 has trouble referencing the CI super object within application constructors
|
| 204 | since objects do not exist until the class is fully instantiated.</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 205 |
|
| 206 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 207 | <h2>Replacing Native Libraries with Your Versions</h2>
|
| 208 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 209 | <p>Simply by naming your class files identically to a native library will cause CodeIgniter to use it instead of the native one. To use this
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 210 | feature you must name the file and the class declaration exactly the same as the native library. For example, to replace the native <kbd>Email</kbd> library
|
admin | 79c643d | 2006-09-28 07:26:21 +0000 | [diff] [blame] | 211 | you'll create a file named <dfn>application/libraries/Email.php</dfn>, and declare your class with:</p>
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 212 |
|
| 213 | <code>
|
| 214 | class CI_Email {<br /><br />
|
| 215 |
|
| 216 | }</code>
|
| 217 |
|
| 218 | <p>Note that most native classes are prefixed with <kbd>CI_</kbd>.</p>
|
| 219 |
|
| 220 | <p>To load your library you'll see the standard loading function:</p>
|
| 221 |
|
| 222 | <code>$this->load->library('<kbd>email</kbd>');</code>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 223 |
|
Derek Allard | 7a1f516 | 2007-01-27 18:02:09 +0000 | [diff] [blame] | 224 | <p class="important"><strong>Note:</strong> At this time the Database classes can not be replaced with your own versions.</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 225 |
|
| 226 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 227 | <h2>Extending Native Libraries</h2>
|
| 228 |
|
| 229 | <p>If all you need to do is add some functionality to an existing library - perhaps add a function or two - then
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 230 | it's overkill to replace the entire library with your version. In this case it's better to simply extend the class.
|
| 231 | Extending a class is nearly identical to replacing a class with a couple exceptions:</p>
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 232 |
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 233 | <ul>
|
| 234 | <li>The class declaration must extend the parent class.</li>
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 235 | <li>Your new class name and filename must be prefixed with <kbd>MY_</kbd> (this item is configurable. See below.).</li>
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 236 | </ul>
|
| 237 |
|
| 238 | <p>For example, to extend the native <kbd>Email</kbd> class you'll create a file named <dfn>application/libraries/</dfn><kbd>MY_Email.php</kbd>, and declare your class with:</p>
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 239 |
|
| 240 | <code>
|
| 241 | class MY_Email extends CI_Email {<br /><br />
|
| 242 |
|
| 243 | }</code>
|
| 244 |
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 245 | <p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p>
|
| 246 |
|
| 247 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 248 | <code>
|
| 249 | class MY_Email extends CI_Email {<br />
|
| 250 | <br />
|
| 251 | function My_Email()<br />
|
| 252 | {<br />
|
| 253 | parent::CI_Email();<br />
|
| 254 | }<br />
|
| 255 | }</code>
|
| 256 |
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 257 |
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 258 | <h3>Loading Your Sub-class</h3>
|
| 259 |
|
| 260 | <p>To load your sub-class you'll use the standard syntax normally used. DO NOT include your prefix. For example,
|
| 261 | to load the example above, which extends the Email class, you will use:</p>
|
| 262 |
|
| 263 | <code>$this->load->library('<kbd>email</kbd>');</code>
|
admin | e1bf942 | 2006-09-28 07:15:05 +0000 | [diff] [blame] | 264 |
|
admin | e334c47 | 2006-10-21 19:44:22 +0000 | [diff] [blame] | 265 | <p>Once loaded you will use the class variable as you normally would for the class you are extending. In the case of
|
Derek Allard | c644128 | 2007-07-04 23:54:32 +0000 | [diff] [blame] | 266 | the email class all calls will use:</p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 267 |
|
| 268 |
|
admin | cf49390 | 2006-10-10 07:12:31 +0000 | [diff] [blame] | 269 | <code>$this-><kbd>email</kbd>->some_function();</code>
|
admin | 79c643d | 2006-09-28 07:26:21 +0000 | [diff] [blame] | 270 |
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 271 |
|
| 272 | <h3>Setting Your Own Prefix</h3>
|
| 273 |
|
| 274 | <p>To set your own sub-class prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p>
|
| 275 |
|
| 276 | <code>$config['subclass_prefix'] = 'MY_';</code>
|
| 277 |
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 278 | <p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p>
|
admin | 0625e19 | 2006-10-20 22:16:54 +0000 | [diff] [blame] | 279 |
|
| 280 |
|
| 281 |
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 282 | </div>
|
| 283 | <!-- END CONTENT -->
|
| 284 |
|
| 285 |
|
| 286 | <div id="footer">
|
| 287 | <p>
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 288 | Previous Topic: <a href="libraries.html">Using CodeIgniter Libraries</a>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 289 | ·
|
| 290 | <a href="#top">Top of Page</a> ·
|
| 291 | <a href="../index.html">User Guide Home</a> ·
|
admin | a634e56 | 2006-08-25 22:19:55 +0000 | [diff] [blame] | 292 | Next Topic: <a href="core_classes.html">Creating Core System Classes</a>
|
Derek Allard | c644128 | 2007-07-04 23:54:32 +0000 | [diff] [blame] | 293 | </p>
|
Derek Jones | 0787043 | 2008-02-13 03:49:26 +0000 | [diff] [blame] | 294 | <p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2008 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 295 | </div>
|
| 296 |
|
| 297 | </body>
|
| 298 | </html> |