CodeIgniter 4 is a rewrite of the framework and is not backwards compatible. It is more appropriate to think of converting your app, rather than upgrading it. Once you have done that, upgrading from one version of CodeIgniter 4 to the next will be straightforward.
The “lean, mean and simple” philosophy has been retained, but the implementation has a lot of differences, compared to CodeIgniter 3.
There is no 12-step checklist for upgrading. Instead, start with a copy of CodeIgniter 4 in a new project folder, however you wish to install and use it, and then convert and integrate your app components. We’ll try to point out the most important considerations here.
Not all of the CI3 libraries have been ported or rewritten for CI4! See the threads in the CodeIgniter 4 Roadmap subforum for an up-to-date list!
Do read the user guide before embarking on a project conversion!
Downloads
Namespaces
Application Structure
application
folder is renamed as app
and the framework still has system
folders, with the same interpretation as beforepublic
folder, intended as the document root for your appwritable
folder, to hold cache data, logs, and session dataapp
folder looks very similar to application
for CI3, with some name changes, and some subfolders moved to the writable
folderapplication/core
folder, as we have a different mechanism for extending framework components (see below)Class loading
Services
App
(application) and CodeIgniter
(i.e. system) top level namespaces; with composer autoloading support, and even using educated guessing to find your models and libraries if they are in the right folder even though not namespacedControllers
Request
and Response
objects for you to work with - more powerful than the CI3-wayModels
Entity
class you can build on, for richer data mapping to your database tables$this->load->model(x);
, you would now use $this->x = new X();
, following namespaced conventions for your componentViews
$this->load->view(x);
you can use echo view(x);
Libraries
app/Libraries
, but they don’t have to$this->load->library(x);
you can now use $this->x = new X();
, following namespaced conventions for your componentHelpers
Events
$hook['post_controller_constructor']
you now use
Events::on('post_controller_constructor', ['MyClass', 'MyFunction']);
, with the namespaceCodeIgniter\Events\Events;
From Codeigniter forum
Required fields are marked *
Get all latest content delivered to your email free.