0
votes

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

404 error

Anyone has any lead on this? Perhaps some documentation or step i missed?

Thanks in advance.

3
yii.local is for backend ? frontend? - ScaisEdge
frontend, perhaps it should be backend? - Rohr Facu
DocumentRoot C:\Apache24\htdocs\yii2\advanced\backend\web ServerName yii.local This is my config - Rohr Facu
you have site on internet for yii.local or you are in localhost ? .. - ScaisEdge
I am in localhost - Rohr Facu

3 Answers

1
votes

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

0
votes

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.