yaf性能測試(wamp環境)

1實現mvcjavascript

出現helloword,成功css

2.controller重定向html

$get = $this->getRequest()->getQuery("get", "default value");

        //2. fetch model
        $model = new SampleModel();
        $this->forward("login");
        //3. assign
        $this->getView()->assign("content", $model->selectSample());
        $this->getView()->assign("name", $name);

 

 $this->forward("login");java

會出現兩個index模版和login模版同時加載的狀況。git

$this->redirect("index/login");github

public function indexAction($name = "Stranger") {
        //1. fetch query
        $get = $this->getRequest()->getQuery("get", "default value");

        //2. fetch model
        $model = new SampleModel();
        $this->redirect("index/login");
        //3. assign
        $this->getView()->assign("content", $model->selectSample());
        $this->getView()->assign("name", $name);

        //4. render by Yaf, 若是這裏返回FALSE, Yaf將不會調用自動視圖引擎Render模板
        return TRUE;
    }

會重定向到http://localhost/yafdemo/index/login成功跳轉數據庫

3.model模式mvc

在使用本身編寫的數據庫操做類的時候,沒遇到什麼問題。ide

public function _initDatabase()
    {
        $db_config['hostname'] = $this->arrConfig->db->hostname;
        $db_config['username'] = $this->arrConfig->db->username;
        $db_config['password'] = $this->arrConfig->db->password;
        $db_config['database'] = $this->arrConfig->db->database;
        // $db_config['log']      = $this->arrConfig->db->log;
        header("Content-type: text/html; charset=utf-8"); 
        Yaf_Registry::set('db', new Db($db_config));
    }

4.路由測試post

$router = Yaf_Dispatcher::getInstance()->getRouter();
        // $route = new Yaf_Route_Rewrite('product/:ident',array('module'=>'User','controller' => 'Index','action' => 'test'));
           //使用路由器裝載路由協議
           //$router->addRoute('product', $route);
        $route = new Yaf_Route_Rewrite('cc',array('controller' => 'Index','action' => 'index'));
        //使用路由器裝載路由協議
        $router->addRoute('cc', $route);

路由還有能夠在aplication.ini配置的模式,大同小異。

5.引用css,js測試

發現一個問題,就是localhost/public/js/public.js這樣的路徑竟然不能夠,可是../public/js/public.js卻能夠,很神奇。

<html>
<link rel="stylesheet" href="<?=BASICURL?>public/css/common.css" type="text/css">
<script type="text/javascript" src="<?=BASICURL?>public/js/public.js"></script>
<body>

<form action="../index/login" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="hidden" value="1" name="submit">
<input type="submit">
</form>
<div>1</div>

</body>
</html>

六、表單測試

表單測試沒有問題。

<html>
<link rel="stylesheet" href="<?=BASICURL?>public/css/common.css" type="text/css">
<script type="text/javascript" src="<?=BASICURL?>public/js/public.js"></script>
<body>

<form action="../index/login" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="hidden" value="1" name="submit">
<input type="submit">
</form>
<div>1</div>

</body>
</html>

具體下載地址https://github.com/Wen1750686723/yafdemo 

若是想看yaf在wamp上如何安裝,請看上篇。

相關文章
相關標籤/搜索