use yii\helpers\Url; // Generate a URL for the 'view' action in the 'post' controller $postUrl = Url::toRoute(['post/view', 'id' => 123]); // Output: "/index.php?r=post%2Fview&id=123" echo $postUrl;
use yii\helpers\Url; // Generate a URL for the 'index' action in the 'admin' module $adminUrl = Url::toRoute(['/admin/default/index']); // Output: "/index.php?r=admin%2Fdefault%2Findex" echo $adminUrl;In this example, `Url::toRoute` is used to generate a URL for the `index` action in the `default` controller of the `admin` module. Package library: Yii framework (yii\helpers\Url)