What is New In CodeIgniter 4.x ?
- Posted On: April 11, 2020 By Harshita Jain
February 2020 update (CodieIgniter 4 was launched)
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.
Following features of CodeIgniter 4
- It required the *intl* extension of PHP installed on the server.
- If we would like to use CURLRequest, we will need a lib curl installed.
- Supported databases are:
- MySQL (5.1+) via the MySQLi driver
- PostgreSQL via the Postgre driver
- SqLite3 via the SQLite3 driver
- CodeIgniter 4 can also be used with command-line programs. As per the latest trend, most of the frameworks provide CLI usability and library. Since Codeigniter 4.x the framework will also be providing CLI interfaces for different purposes.
- The following PHP extensions should be enabled on your server:
- If you want to use CURLRequest in your CI application, you will need to install libcurl.
- The framework now provides for a public folder, intended as the document root for your app.
- Hooks in Codeigniter are a great feature that is maintained and improved as well.
Comparison between Codeigniter 4.x with Codeigniter 3.x
CodeIgniter 4 is very different from 3 and below you will see a little about the main differences between them.
- Support for PHP versions - To use CodeIgniter 4 the minimum PHP version required is 7.2, while with CodeIgniter 3 it is possible to use version 5.6 (which has already been completely discontinued).
- Directory organization – The file structure is completely different. CodeIgniter 4 has its structure organized in 5 directories: /app,/system,/public,/writable,/tests. While CodeIgniter 3 is organized in 2 directories:/application and/system`.
- Use of namespaces - CodeIgniter 4 is written entirely in PHP 7 and makes use of namespaces, while CodeIgniter 3 does not use namespaces.
- Autoloading - 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.
- Use of Entities - 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.
- Performance - 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.
- Monolithic Libraries - Unlike CodeIgniter 3, in this new version the use of monolithic libraries in the PEAR style is almost zero.
- Settings - 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.
- Native support for .env files - 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.
- Migration between versions - 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.
How to install Codeigniter 4?
Codeigniter 4 can be installed using many methods
- In Manual Installation, you need to download the latest release from the official site and can place it in your www/htdocs directory after extracting it.Note: This is the installation technique closest to that described for CodeIgniter 3.
- If you want to use the composer tool you need to install the composer first and then you can install using the command line. Composer will also help you to add third-party plugins in your project in the future.
- You can download and install the composer from this link: https://getcomposer.org/
- You can also clone the git repository of CodeIgniter.
We should use CodeIgniter 4 because we have new features along with security. .
The most striking and obvious change to the previous versions is the fact that there is now a public directory.
Due to the fact that the framework will be revealed not so freely, it is much more difficult for potential attackers to find vulnerabilities or deliberately exploit.