How to create route in yii?

Yii – URL Routing

  1. Step 1 − Modify the config/web. …
  2. Step 2 − Got to http://localhost:8080/index.php. …
  3. Step 3 − Add the following function to the SiteController.
  4. Step 4 − Then, modify the config/web. …
  5. Step 5 − Now enter any URL of your application, you will see the following.

How routing works in yii?

When a Yii application starts processing a requested URL, the first step it takes is to parse the URL into a route. The route is then used to instantiate the corresponding controller action to handle the request. This whole process is called routing.

How can I get base URL in Yii?

Anytime you see get as the function base name, it is a getter function. Meaning you can just do: Yii::$app->urlManager->baseUrl .