How do I Migrate from 4.3.x to 4.4.x? |
Here is a list of some of the major changes that you will need to make when migrating from CodeIgniter 4.3.x to 4.4.x:
Controllers no longer use echo to spew views. Instead they use return. This means that you will need to change all of your controller methods that currently use echo to return the view instead. For example: PHP // CodeIgniter 4.3.x public function index() { echo view('pages/index'); } // CodeIgniter 4.4.x public function index() { return view('pages/index'); } The $routes array now uses PHP 8.1 named arguments. This means that you will need to change all of your $routes array definitions to use named arguments instead of positional arguments. For example: PHP // CodeIgniter 4.3.x $routes->get('pages/index', 'Pages::index'); // CodeIgniter 4.4.x $routes->get('pages/index', [Pages::class, 'index']); The Database::connect() method now returns a ConnectionPool object. This means that you will need to change all of your code that currently uses the Database::connect() method to return the ConnectionPool object instead. For example: PHP // CodeIgniter 4.3.x $db = Database::connect(); // CodeIgniter 4.4.x $db = Database::connect()->getConnection('default'); The Validation::check() method now accepts a string or array of validation rules as its second argument. This means that you will need to change all of your code that currently uses the Validation::check() method to accept a string or array of validation rules as its second argument instead of a single validation rule. For example: PHP // CodeIgniter 4.3.x $validation->check($input, 'required'); // CodeIgniter 4.4.x $validation->check($input, ['required', 'min_length' => 5]); The Security::encrypt() and Security::decrypt() methods now accept a string or array of data as their first argument. This means that you will need to change all of your code that currently uses the Security::encrypt() and Security::decrypt() methods to accept a string or array of data as their first argument instead of a single piece of data. For example: PHP // CodeIgniter 4.3.x $encryptedData = Security::encrypt($data); // CodeIgniter 4.4.x $encryptedData = Security::encrypt(['data' => $data]); These are just some of the major changes that you will need to make when migrating from CodeIgniter 4.3.x to 4.4.x. For a more comprehensive list of changes, please consult the CodeIgniter 4.4 upgrade guide. I hope this helps! |
Messages In This Thread |
How do I Migrate from 4.3.x to 4.4.x? - by owino - 09-30-2023, 01:27 AM
RE: How do I Migrate from 4.3.x to 4.4.x? - by JustJohnQ - 09-30-2023, 01:38 AM
RE: How do I Migrate from 4.3.x to 4.4.x? - by ozornick - 09-30-2023, 04:26 AM
RE: How do I Migrate from 4.3.x to 4.4.x? - by kenjis - 09-30-2023, 05:36 PM
RE: How do I Migrate from 4.3.x to 4.4.x? - by kenjis - 09-30-2023, 05:41 PM
RE: How do I Migrate from 4.3.x to 4.4.x? - by AnanayKayar - 10-27-2023, 04:32 AM
RE: How do I Migrate from 4.3.x to 4.4.x? - by kenjis - 10-27-2023, 02:52 PM
|