Note
These upgrade notes are for a version that is yet to be released.
Before performing an update you should take your site offline by replacing the index.php file with a static one.
Replace all files and directories in your "system" folder and replace your index.php file. If any modifications were made to your index.php they will need to be made fresh in this new one.
Note
If you have any custom developed files in these folders please make copies of them first.
Starting with CodeIgniter 3.0, all class filenames (libraries, drivers, controllers and models) must be named in a Ucfirst-like manner or in other words - they must start with a capital letter.
For example, if you have the following library file:
application/libraries/mylibrary.php
... then you'll have to rename it to:
application/libraries/Mylibrary.php
The same goes for driver libraries and extensions and/or overrides of CodeIgniter's own libraries and core classes.
application/libraries/MY_email.php application/core/MY_log.php
The above files should respectively be renamed to the following:
application/libraries/MY_Email.php application/core/MY_Log.php
Controllers:
application/controllers/welcome.php -> application/controllers/Welcome.php
Models:
application/models/misc_model.php -> application/models/Misc_model.php
Please note that this DOES NOT affect directories, configuration files, views, helpers, hooks and anything else - it is only applied to classes.
You must now follow just one simple rule - class names in Ucfirst and everything else in lowercase.
This config file has been updated to contain more user mime-types, please copy it to _application/config/mimes.php*.
Use of the $autoload['core']
config array has been deprecated as of CodeIgniter 1.4.1 and is now removed. Move any entries that you might have listed there to $autoload['libraries']
instead.
The Log Class is considered as a "core" class and is now located in the system/core/ directory. Therefore, in order for your Log class overrides or extensions to work, you need to move them to application/core/:
application/libraries/Log.php -> application/core/Log.php
application/libraries/MY_Log.php -> application/core/MY_Log.php
When you load (or autoload) the Session library, you must now load it as a driver instead of a library. This means calling $this->load->driver('session')
instead of $this->load->library('session')
and/or listing 'session' in $autoload['drivers']
instead of $autoload['libraries']
.
With the change from a single Session Library to the new Session Driver, two new config items have been added:
$config['sess_driver']
selects which driver to initially load. Options are:
- 'cookie' (the default) for classic CodeIgniter cookie-based sessions
- 'native' for native PHP Session support
- the name of a custom driver you have provided (see
Session Driver <../libraries/sessions>
for more info)$config['sess_valid_drivers']
provides an array of additional custom drivers to make available for loading
As the new Session Driver library loads the classic Cookie driver by default and always makes 'cookie' and 'native' available as valid drivers, neither of these configuration items are required. However, it is recommended that you add them for clarity and ease of configuration in the future.
If you have written a Session extension, you must move it into a 'Session' sub-directory of 'libraries', following the standard for Drivers. Also beware that some functions which are not part of the external Session API have moved into the drivers, so your extension may have to be broken down into separate library and driver class extensions.
Due to 3.0.0's renaming of Active Record to Query Builder, inside your config/database.php, you will need to rename the $active_record variable to $query_builder :
$active_group = 'default';
// $active_record = TRUE;
$query_builder = TRUE;
In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*.
Historically, CodeIgniter has always provided the :any wildcard in routing, with the intention of providing a way to match any character within an URI segment.
However, the :any wildcard is actually just an alias for a regular expression and used to be executed in that manner as .+. This is considered a bug, as it also matches the / (forward slash) character, which is the URI segment delimiter and that was never the intention. In CodeIgniter 3, the :any wildcard will now represent [^/]+, so that it will not match a forward slash.
There are certainly many developers that have utilized this bug as an actual feature. If you're one of them and want to match a forward slash, please use the .+ regular expression:
(.+) // matches ANYTHING
(:any) // matches any character, except for '/'
Many methods and functions now return NULL instead of FALSE when the required items don't exist:
Config Class <../libraries/config>
- config->item()
- config->slash_item()
Input Class <../libraries/input>
- input->get()
- input->post()
- input->get_post()
- input->cookie()
- input->server()
- input->input_stream()
- input->get_request_header()
Session Class <../libraries/sessions>
- session->userdata()
- session->flashdata()
URI Class <../libraries/uri>
- uri->segment()
- uri->rsegment()
Array Helper <../helpers/array_helper>
- element()
- elements()
In the resulting array, directories now end with a trailing directory separator (i.e. a slash, usually).
Up until now, drop_table()
added an IF EXISTS clause by default or it didn't work at all with some drivers. In CodeIgniter 3.0, the IF EXISTS condition is no longer added by default and has an optional second parameter that allows that instead and is set to FALSE by default.
If your application relies on IF EXISTS, you'll have to change its usage.
// Now produces just DROP TABLE `table_name`
$this->dbforge->drop_table('table_name');
// Produces DROP TABLE IF EXISTS `table_name`
$this->dbforge->drop_table('table_name', TRUE);
Note
The given example uses MySQL-specific syntax, but it should work across all drivers with the exception of ODBC.
The Email Library <../libraries/email>
will automatically clear the set parameters after successfully sending emails. To override this behaviour, pass FALSE as the first parameter in the send()
method:
if ($this->email->send(FALSE))
{
// Parameters won't be cleared
}
Two improvements have been made to the Form Validation Library
<../libraries/form_validation>
's language <../libraries/language>
files and error messages format:
Language Library <../libraries/language>
line keys now must be prefixed with form_validation_ in order to avoid collisions:// Old $lang['rule'] = ... // New $lang['form_validation_rule'] = ...
The error messages format has been changed to use named parameters, to allow more flexibility than what sprintf() offers:
// Old 'The %s field does not match the %s field.' // New 'The {field} field does not match the {param} field.'
Note
The old formatting still works, but the non-prefixed line keys are DEPRECATED and scheduled for removal in CodeIgniter 3.1+. Therefore you're encouraged to update its usage sooner rather than later.
In addition to the $autoload['core']
configuration setting, there's a number of other functionalities that have been removed in CodeIgniter 3.0.0:
The previously deprecated SHA1 library has been removed, alter your code to use PHP's native sha1()
function to generate a SHA1 hash.
Additionally, the sha1()
method in the Encryption Library <../libraries/encryption>
has been removed.
Usage of the EXT
constant has been deprecated since dropping support for PHP 4. There's no longer a need to maintain different filename extensions and in this new CodeIgniter version, the EXT
constant has been removed. Use just '.php' instead.
Smiley Helper <../helpers/smiley_helper>
function js_insert_smiley()
has been deprecated since CodeIgniter 1.7.2 and is now removed. You'll need to switch to smiley_js()
instead.
Security Helper <../helpers/security_helper>
function do_hash()
is now just an alias for PHP's native hash()
function. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
This function is still available, but you're strongly encouraged to remove its usage sooner rather than later.
File Helper <../helpers/file_helper>
function read_file()
is now just an alias for PHP's native file_get_contents()
function. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
This function is still available, but you're strongly encouraged to remove its usage sooner rather than later.
String Helper <../helpers/string_helper>
function :phprepeater()
is now just an alias for PHP's native str_repeat()
function. It is deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
This function is still available, but you're strongly encouraged to remove its usage sooner rather than later.
String Helper <../helpers/string_helper>
function :phptrim_slashes()
is now just an alias for PHP's native trim()
function (with a slash passed as its second argument). It is deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
This function is still available, but you're strongly encouraged to remove its usage sooner rather than later.
Email Helper <../helpers/email_helper>
only has two functions
- :php
valid_email()
- :php
send_email()
Both of them are now aliases for PHP's native filter_var()
and mail()
functions, respectively. Therefore the Email Helper <../helpers/email_helper>
altogether is being deprecated and is scheduled for removal in CodeIgniter 3.1+.
Note
These functions are still available, but you're strongly encouraged to remove their usage sooner rather than later.
Date Helper <../helpers/date_helper>
function standard_date()
is being deprecated due to the availability of native PHP constants, which when combined with date()
provide the same functionality. Furthermore, they have the exact same names as the ones supported by standard_date()
. Here are examples of how to replace its usage:
// Old way
standard_date(); // defaults to standard_date('DATE_RFC822', now());
// Replacement
date(DATE_RFC822, now());
// Old way
standard_date('DATE_ATOM', $time);
// Replacement
date(DATE_ATOM, $time);
Note
This function is still available, but you're strongly encouraged to remove its usage sooner rather than later as it is scheduled for removal in CodeIgniter 3.1+.
The Pagination Library <../libraries/pagination>
now supports adding pretty much any HTML attribute to your anchors via the 'attributes' configuration setting. This includes passing the 'class' attribute and using the separate 'anchor_class' setting no longer makes sense. As a result of that, the 'anchor_class' setting is now deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
This setting is still available, but you're strongly encouraged to remove its usage sooner rather than later.
When using the String Helper <../helpers/string_helper>
function :phprandom_string()
, you should no longer pass the unique and encrypt randomization types. They are only aliases for md5 and sha1 respectively and are now deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
These options are still available, but you're strongly encouraged to remove their usage sooner rather than later.
When using the URL Helper <../helpers/url_helper>
function :phpurl_title()
, you should no longer pass dash or underscore as the word separator. This function will now accept any character and you should just pass the chosen character directly, so you should write '-' instead of 'dash' and '_' instead of 'underscore'.
dash and underscore now act as aliases and are deprecated and scheduled for removal in CodeIgniter 3.1+.
Note
These options are still available, but you're strongly encouraged to remove their usage sooner rather than later.
If you have used the third parameter for Database Forge <../database/forge>
method add_column()
to add a field for an AFTER clause, then you should change its usage.
That third parameter has been deprecated and scheduled for removal in CodeIgniter 3.1+.
You should now put AFTER clause field names in the field definition array instead:
// Old usage:
$field = array(
'new_field' => array('type' => 'TEXT')
);
$this->dbforge->add_column('table_name', $field, 'another_field');
// New usage:
$field = array(
'new_field' => array('type' => 'TEXT', 'after' => 'another_field')
);
$this->dbforge->add_column('table_name', $field);
Note
The parameter is still available, but you're strongly encouraged to remove its usage sooner rather than later.
Note
This is for MySQL and CUBRID databases only! Other drivers don't support this clause and will silently ignore it.
With properties CI_Router::$directory
, CI_Router::$class
and CI_Router::$method
being public and their respective fetch_*()
no longer doing anything else to just return the properties - it doesn't make sense to keep them.
Those are all internal, undocumented methods, but we've opted to deprecate them for now in order to maintain backwards-compatibility just in case. If some of you have utilized them, then you can now just access the properties instead:
$this->router->directory;
$this->router->class;
$this->router->method;
Note
Those methods are still available, but you're strongly encouraged to remove their usage sooner rather than later.