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上如何安装,请看上篇。

相关文章
相关标签/搜索