Before we talk about the differences, we need to know a little bit about what happened in the time between the release of version 3 and the version.
Between the launch of the first stable version of CodeIgniter 3 and that of CodeIgniter 4, it took almost 5 years, 1767 days to be more precise.
In that time much has changed on the internet, 8 versions of PHP were launched, several other PHP frameworks appeared and those that were already on the market were being updated.
Meanwhile CodeIgniter was lagging behind, going from being one of the main PHP frameworks to becoming one of the most outdated. But all was not lost, EllisLab who was primarily responsible for the development of CodeIgniter passed the baton to BCIT and then thanks to the work of Jim Perry (in memorian) and an incredibly dedicated community, CodeIgniter started to come to life and the version 4 won its first alpha on September 28, 2018.
On February 24, 2020, which would be Jim Perry's birthday, CodeIgniter 4 was launched, in honor of the professional who he devoted a good part of his time in bringing the framework back to the market, with conditions to compete with the other existing frameworks and more updated in relation to resources and PHP itself.
CodeIgniter 4 is very different from 3 and below you will see a little about the main differences between them.
To use CodeIgniter 4 the minimum PHP version required is 7.2, while with CodeIgniter 3 it is possible to use from version 5.6 (which has already been completely discontinued).
The file structure is completely different. CodeIgniter 4 has its structure organized in 5 directories: /app
. While CodeIgniter 3 is organized in 2 directories:/application
CodeIgniter 4 is written entirely in PHP 7 and makes use of namespaces, while CodeIgniter 3 does not use namespaces.
CodeIgniter 4 has a much more efficient autoload process, and one of the factors that help is the use of namespaces. While in CodeIgniter 3 it is necessary to manually configure most of the files to be loaded.
CodeIgniter 4 has native support for the use of Entities (entities) that help in structuring the database part of an application, representing the existing columns in the tables. CodeIgniter 3 did not have this feature and anyone who needed to use it needed to use third-party libraries and make adjustments to the file upload to support it.
CodeIgniter 4, for using PHP 7 in writing and as a minimum configuration on the server, and other aspects, has a better performance than CodeIgniter 3.
Unlike CodeIgniter 3, in this new version the use of monolithic libraries in the PEAR style is almost zero.
With CodeIgniter 4, the initial settings for your application to start running are minimal, while in CodeIgniter 3 it was necessary to perform a good number of configurations.
CodeIgniter 4 has native support for .env files, allowing an optimization of the settings of the different environments where it may be running (production, tests, development). This feature did not exist natively in CodeIgniter 3.
CodeIgniter 4 is not backward compatible, so the process of updating applications from version 3 to version 4 will require a little more work, but it is not at all complicated.
While the migration from version 2.x to 3.x, and between the different versions 3.x was just overwriting the files in the
/system directory and updating the name of some files, from version 3 to four a new structure is needed for the application and a rewrite of all the classes used in it to adapt to the new standard.
These are some of the main differences between versions 3 and 4 of CodeIgniter. Stay tuned here that has a lot of content about CodeIgniter 4 being produced.