yaf安装配置

  简单了解yaf之后,开始进行yaf的配置,我使用的是php+nginx+mysql,在window系统下安装。

  第一步   将yaf.dll,yar.dll放到php\ext目录下

  第二步    在php.ini里加入extension=yaf.dll   extension=yar.dll

  第三步,重启服务器,在一个php文件里输入phpinfo(),运行,如果出现yaf的版本信息,则安装成功

  

  yaf的目录结构

  -index.php       //入口文件

  -public

  -conf

    --application.ini        //配置文件

  -application

    --controllers

      ---index.php          //默认控制器

    --views

      ---index                //控制器

        ----index.phtml   //默认视图

    --modules  //其他模块

    --library    //本地类库

    --models   //model目录

    --plugins  //插件目录  

  index.php入口文件的内容:

    define("APP_PATH", dirname(__FILE__));

    $app = new Yaf_Application(APP_PATH."/conf/application.in");

    $app->run();

  Nginx.conf修改:

    server{

    listen 80;

    server_name   www.yaf.com;

    root    你的应用所在的目录;

    index  index.php index.html index.htm;

    

    if (!-e $request_filename) {     rewrite ^/(.*)  /index.php/$1 last;   }

 

      location ~* \.php$ {   include php.conf;  }

    }

  

  yaf配置时遇到的问题:

  把rewrite ^/(.*)  /index.php/$1 last;改成rewrite ^/(.*)  /index.php?$1 last;

  以前看了篇帖子讲了原因的,不过忘记了。

 

  默认控制器application/controllers/Index.php

    class IndexController extends Yaf_Controller_Abstract

  {

    public function indexAction()

    {

      $this->getView()->assign("content", "hello world");

    }

  }

  然后在浏览器中输入   www.yaf.com就可以看到hello world 了。

 

  

  

posted @ 2014-06-04 18:11  fendor  阅读(768)  评论(0编辑  收藏  举报