Home > Software engineering >  How do you convert a CodeIgniter 2 project to CodeIgniter 4?
How do you convert a CodeIgniter 2 project to CodeIgniter 4?

Time:03-21

I have one old CodeIgniter 2 project.

How do I update/upgrade it to CodeIgniter version 4 without any code or function change?

Is it possible?

CodePudding user response:

There is no point in upgrading from 2 to 3 since at the end of the day you won't be able to smoothly upgrade from 3 to 4. Just come to terms with your current situation that a complete project rewrite may be necessary. Nonetheless, you may be able to save some parts of your old project.

Upgrading from 3.x to 4.x

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.

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.

CodePudding user response:

There is no upgrade path to go from version 3 to 4, especially if you do not want to do any code or function changes, but I disagree that there is no point to upgrading to version 3. Actually, you will be unable to upgrade to even CI 3 without code or function changes. That ruled out, meaning you HAVE to change code or functions, the following might help.

Before you cut your losses and redevelop as suggested, using the below work from Kenji a shot might help. But to do so, you need to upgrade to CI 3 first. Kenji is a very accomplished CI developer with lots of contributions to the framework, including a PHP Unit wrapper for CI. You could follow the guides and upgrade to version 3, and then try to use this: https://github.com/kenjis/ci3-to-4-upgrade-helper/tree/1.x/src/CI3Compatible

The steps to upgrade from version 2 to version 3 may be a big job as well, the biggest one being the initial step - not saying it is going to be easy, but if you try this, and it is not working for you, redeveloping might be your last resort.

For completeness, CI 3.1.13 has been released, and CI is thus now PHP 8.1.3 compatible. The upgrade process from 3.1.11 that I had in my projects to 3.1.13 was literally as easy as 1-2-3.

  • Related