1. 下载

https://github.com/laruence/yaf/archive/master.zip

2. 找到yaf_cg文件

cd yaf-master/tools/cg

3. 创建项目

./yaf_cg testAPI

4. 项目会出现在yaf_cg同级目录中的output文件夹中

cd output/testAPI

一个最精简的Yaf项目就生成了

5. 它的index.php是入口文件,使用conf中的配置文件调用Bootstrap,把这个项目跑起来

6. Bootstrap.php是开发过程中的入口,很多基础功能都是在这里先注册的

YAF_API

index.php --->>> 加载conf中的文件 --->>>调用Bootstrap.php --->>> 根据请求里的controller和action的定义找到对应的controller

YAF的rewrite规则,适合大部分项目

$router = Yaf_Dispatcher::getInstance()->getRouter();

$route = new Yaf_Route_Rewrite(
    'product/:ident',
    array(
        'controller' => 'products',
        'action' => 'view'
    )
);

$router->addRoute('product', $route);

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐