Sabtu, 25 Oktober 2014

Hello World in YII2


1. Deklarasikan pada controller, edit di controllers/SiteController.php :
namespace app\controllers;
use yii\web\Controller;
class SiteController extends Controller
{
// ...existing code...
public function actionSay($message = ’Hello’)
{
return $this->render(’say’, [’message’ => $message]);
}
}

2. Buat view untuk memanggil controller :

use yii\helpers\Html;
?>

simpan file di views/site/say.php

3. Panggil di browser :

http://localhost/latyii2/frontend/web/index.php?r=site/say



Previous Post
Next Post