Skip to main content
PHP Blog

Back to all posts

How to Define A New Controller In Yii 2?

Published on
7 min read

Table of Contents

Show more
How to Define A New Controller In Yii 2? image

To define a new controller in Yii 2, follow these steps:

  1. Create a new PHP file in the controllers directory of your Yii 2 application (usually located in the frontend or backend folder).
  2. Declare a new class that extends the yii\web\Controller class. For example, you can name it YourController.