2

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?

steven7mwesigwa
  • 5,701
  • 3
  • 20
  • 34
  • 2
    It is not possible. Both have very different structure. You will need to rewrite the whole project. – Dhaval Chheda Mar 18 '22 at 05:34
  • If Codeigniter 2 to 3 is possible??? Use this reference https://www.codeigniter.com/userguide3/installation/upgrade_300.html – Nithya Kalyani Mar 18 '22 at 05:45
  • 1
    It makes no sense to upgrade the project the system which is not actively maintained. – Dhaval Chheda Mar 18 '22 at 05:51
  • 1
    from CI 2 to 3 will be easy just follow upgrade documentation. But 2 to 4 or 3 to 4 is complete different structure and code standards. – umefarooq Mar 18 '22 at 06:48
  • It needs a rewrite. Point. Anyway it doesn't make sense to upgrade from CI2 to CI3 and then rewrite your project to fit with CI4. Just do this rewrite with your existing CI2 version. It takes time, but is straight forward, the upgrade guides are awesome, you just need to adapt a bit, the difference of CI2 to CI3 were not that significant. Hint: create your own "cheat-list" in an excel table, notepad or similar, were you have old and new syntax comparison. Also be sure that server requirements fit, before you start. – Vickel May 04 '22 at 23:32

2 Answers2

3

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.

It's a poor time and labour cost calculation advising you to go through two (2 -> 3 -> 4) framework versions if you can efficiently move straight/directly to the latest version. Upgrading a framework alone consumes time, labour and comes with its own set of bugs.

Just come to terms with your current situation that a complete project rewrite directly to CodeIgniter 4 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.


CodeIgniter 3 is in maintenance mode, receiving mostly just security updates.

steven7mwesigwa
  • 5,701
  • 3
  • 20
  • 34
0

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.

Kobus Myburgh
  • 1,114
  • 1
  • 17
  • 46
  • In most cases, time and labour costs are very important in the development process. Why have to go through two hurdles if you have the reasonable option to **only directly** move through the last one? – steven7mwesigwa Mar 21 '22 at 09:12
  • It depends which is the biggest hurdle to get over. Redevelop, or do two upgrades? I have done both in different scenarios. Whether they were the right decisions, I can't always tell, but at the time they were, and they scratched the itch. – Kobus Myburgh Mar 21 '22 at 19:13