I'm new to yii and i'm trying to make the "Saying Hello" yii2 tutorial. I have this on the site controller:
//Code
public function actionSay($message = 'Hello')
{
return $this->render('say', ['message' => $message]);
}
//Code
And this on my say.php view:
<?php
use yii\helpers\Html;
?>
<?= Html::encode($message) ?>
This is my project structure: project structure
However, when i try to access the site (configured as yii.local) to show the say action, i got a 404 Not Found.
http://yii.local/index.php?r=site%2Fsay&message=Hello+World
Anyone has any lead on this? Perhaps some documentation or step i missed?
Thanks in advance.
I think in your controller should be like this:
public function actionSay($message){
#code......
}
and the inside the link, the part after "message=" should be the message that you want to display.
Your controller is Ok and The view file as well.
Please check the url you are trying to access.
Its: yii.local/
I think it should be http://localhost/rest_of_the_url
http://yii.local/index.php?r=site%2Fsay&message=Hello+World
why %2F? Yii2 may recognize it correctly.
http://yii.local/index.php?r=site/say&message=Hello+World doesn't work?