#07 Controllers in CodeIgniter 4

Опубликовано: 05 Октябрь 2024
на канале: GoPHP
24,380
209

What is a Controller ?
Controllers:
The HEART of MVC architecture is Controller, also called as TRAFFIC COP
Each and every request & response is going to handled by Controller Only.

A Controller is a class file, which contains collection of methods and properties.
Controller classes should be saved in app/Controllers folder.
The file must be called ‘Helloworld.php’, with a capital ‘H’. Controller class names MUST start with an uppercase letter and ONLY the first character can be uppercase.
Controller extends the parent controller class so that it can inherit all its methods.

namespace App\Controllers;
use CodeIgniter\Controller;
class Helloworld extends Controller
{
public function index()
{
echo 'Hello World!';
}
}