user_guide_src/source/installation/upgrade_controllers.rst
Upgrade Controllers ###################
.. contents:: :local: :depth: 2
Controller Documentation CodeIgniter 3.x <http://codeigniter.com/userguide3/general/controllers.html>_Controller Documentation CodeIgniter 4.x </incoming/controllers>initController() <controller-constructor>.Request </incoming/incomingrequest> and :doc:Responses </outgoing/response>
objects for you to work with - more powerful than the CI3-way.MY_Controller in CI3), use app/Controllers/BaseController.php.echo within Controllers, as in CI3, is still supported, but
it is recommended that a string or Response object be returned from Controllers.namespace App\Controllers;extends CI_Controller with extends BaseController.defined('BASEPATH') OR exit('No direct script access allowed'); if it exists.| If you use sub-directories in your controller structure, you have to change the namespace according to that.
| For example, you have a version 3 controller located in application/controllers/users/auth/Register.php,
the namespace has to be namespace App\Controllers\Users\Auth; and the controller path in the version 4
should look like this: app/Controllers/Users/Auth/Register.php. Make sure to have the first letters of
the sub-directories as capitalized.
| After that you have to insert a use statement below the namespace definition in order to extend the BaseController:
use App\Controllers\BaseController;
Path: application/controllers:
.. literalinclude:: upgrade_controllers/ci3sample/001.php
Path: app/Controllers:
.. literalinclude:: upgrade_controllers/001.php