<?php
安装
phpize
./configure --with-php-config=/usr/local/php/bin/php-config 路由类
final Yaf_Router {
protected array _routes ;
protected string _current_route ;
public Yaf_Router addRoute ( string $name路由协议的名字 , Yaf_Route_Interface $route );
/*
例如:添加一个路由
class Bootstrap extends Yaf_Bootstrap_Abstract{
public function _initRoute(Yaf_Dispatcher $dispatcher) { $route = new Yaf_Route_Rewrite(
"/product/list/:id/",
array(
"controller" => "product",
"action" => "info",
)
); $router->addRoute('dummy', $route);
}
*/ public boolean addConfig ( Yaf_Config_Abstract $routes_config );
/* 例如:给路由器通过配置增加一簇路由协议
class Bootstrap extends Yaf_Bootstrap_Abstract{
public function _initRoute(Yaf_Dispatcher $dispatcher) {
$router = Yaf_Dispatcher::getInstance()->getRouter();
$router->addConfig(Yaf_Registry::get("config")->routes);
*/ public array getRoutes ( void );// 获取当前路由器中的所有路由协议 例 $routes = Yaf_Dispatcher::getInstance()->getRouter()->getRoutes(); public array getRoute ( string $name );//获取当前路由器的路由协议栈中名为$name的协议 public string getCurrentRoute ( void );//在路由结束以后, 获取路由匹配成功, 路由生效的路由协议名
public boolean route ( Yaf_Request_Abstract $request );//Yaf_Dispatcher::dispatch会自动调用本方法
public boolean isModuleName ( string $name );//判断一个Module名, 是否是申明存在的Module
} 控制器类
abstract Yaf_Controller_Abstract {
protected array actions ;
protected Yaf_Request_Abstract _request ;
protected Yaf_Response_Abstract _response ;
protected Yaf_View_Interface _view ;
protected string _script_path ;
private void __construct ( void );
public void init ( void ); //默认最开始执行
public string getModuleName ( void );
public Yaf_Request_Abstract getRequest ( void );
public Yaf_Response_Abstract getResponse ( void );
public Yaf_View_Interface getView ( void );
public Yaf_View_Interface initView ( void );//初始化视图引擎,因为Yaf采用延迟实例化视图引擎的策略, 所以只有在使用前调用此方法, 视图引擎才会被实例化
public boolean setViewPath ( string $view_directory );
public string getViewPath ( void );
public Yaf_Response_Abstract render ( string $action_name ,array $tpl_vars = NULL );//渲染视图模板, 得到渲染结果
public boolean display ( string $action_name ,array $tpl_vars = NULL );
public boolean forward ( string $action ,array $invoke_args = NULL );
public boolean forward ( string $controller ,string $action ,array $invoke_args = NULL );
public boolean forward ( string $module ,string $controller ,string $action ,array $invoke_args = NULL );
public boolean redirect ( string $url );
} Yaf_View_Simple extends Yaf_View_Interface {
protected array _tpl_vars ;
protected string _script_path ;
public string render ( string $view_path ,array $tpl_vars = NULL ); //渲染一个视图模板, 得到结果 echo $this->getView()->render($this->_script_path . "/test.phtml");
public boolean display ( string $view_path ,array $tpl_vars = NULL );//渲染一个视图模板, 并直接输出给请求端
public boolean setScriptPath ( string $view_directory );//设置模板的基目录, 默认的Yaf_Dispatcher会设置此目录为APPLICATION_PATH . "/views".
public string getScriptPath ( void );
public boolean assign ( string $name ,mixed $value ); //变量分配到了 _tpl_vars属性
public boolean __set ( string $name ,mixed $value = NULL );
public mixed __get ( string $name );
} 请求类
abstract Yaf_Request_Abstract {
protected string _method ;
protected string _module ;
protected string _controller ;
protected string _action ;
protected array _params ;
protected string _language ;
protected string _base_uri ;
protected string _request_uri ;
protected boolean _dispatched ;
protected boolean _routed ;
public string getModuleName ( void );
public string getControllerName ( void );
public string getActionName ( void );
public boolean setModuleName ( string $name );
public boolean setControllerName ( string $name );
public boolean setActionName ( string $name );
public Exception getException ( void );
public mixed getParams ( void );
public mixed getParam ( string $name ,mixed $dafault = NULL );
public mixed setParam ( string $name ,mixed $value );
public mixed getMethod ( void );
abstract public mixed getLanguage ( void );
abstract public mixed getQuery ( string $name = NULL );
abstract public mixed getPost ( string $name = NULL );
abstract public mixed getEnv ( string $name = NULL );
abstract public mixed getServer ( string $name = NULL );
abstract public mixed getCookie ( string $name = NULL );
abstract public mixed getFiles ( string $name = NULL );
abstract public bool isGet ( void );
abstract public bool isPost ( void );
abstract public bool isHead ( void );
abstract public bool isXmlHttpRequest ( void );
abstract public bool isPut ( void );
abstract public bool isDelete ( void );
abstract public bool isOption ( void );
abstract public bool isCli ( void );
public bool isDispatched ( void );
public bool setDispatched ( void );
public bool isRouted ( void );
public bool setRouted ( void );
}
Array
(
[0] => getQuery
[1] => getRequest
[2] => getPost
[3] => getCookie
[4] => getFiles
[5] => get
[6] => isXmlHttpRequest
[7] => __construct
[8] => isGet
[9] => isPost
[10] => isPut
[11] => isHead
[12] => isOptions
[13] => isCli
[14] => getServer
[15] => getEnv
[16] => setParam
[17] => getParam
[18] => getParams
[19] => getException
[20] => getModuleName
[21] => getControllerName
[22] => getActionName
[23] => setModuleName
[24] => setControllerName
[25] => setActionName
[26] => getMethod
[27] => getLanguage
[28] => setBaseUri
[29] => getBaseUri
[30] => getRequestUri
[31] => setRequestUri
[32] => isDispatched
[33] => setDispatched
[34] => isRouted
[35] => setRouted
)
Array
(
[module] =>
[controller] =>
[action] =>
[method] =>
) ///主类///
final Yaf_Application {
protected Yaf_Config _config ;
protected Yaf_Dispatcher _dispatcher ;
protected static Yaf_Application _app ;
protected boolean _run = FALSE ;
protected string _environ ;
protected string _modules ;
public void __construct ( mixed $config ,string $section = ap.environ );
public Yaf_Application bootstrap ( void );
public Yaf_Response_Abstract run ( void );
public Yaf_Dispatcher getDispatcher ( void );
public Yaf_Config_Abstract getConfig ( void );
public string environ ( void );
public string geModules ( void );
public static Yaf_Application app ( void );
public mixed execute ( callback $funcion ,mixed $parameter = NULL ,mixed $... = NULL );
} //分发类
final Yaf_Dispatcher {
protected static Yaf_Dispatcher _instance ;
protected Yaf_Router_Interface _router ;
protected Yaf_View_Abstract _view ;
protected Yaf_Request_Abstract _request ;
protected array _plugins ;
protected boolean _render ;
protected boolean _return_response = FALSE ;
protected boolean _instantly_flush = FALSE ;
protected string _default_module ;
protected string _default_controller ;
protected string _default_action ;
public static Yaf_Dispatcher getInstance ( void );
public Yaf_Dispatcher disableView ( void );
public Yaf_Dispatcher enableView ( void );
public boolean autoRender ( bool $flag );
public Yaf_Dispatcher returnResponse ( boolean $flag );
public Yaf_Dispatcher flushInstantly ( boolean $flag );
public Yaf_Dispatcher setErrorHandler ( mixed $callback ,int $error_type = E_ALL | E_STRICT );
public Yaf_Application getApplication ( void );
public Yaf_Request_Abstract getRequest ( void );
public Yaf_Router_Interface getRouter ( void );
public Yaf_Dispatcher registerPlugin ( Yaf_Plugin_Abstract $plugin );
public Boolean setAppDirectory ( string $directory );
public Yaf_Dispatcher setRequest ( Yaf_Request_Abstract $request );
public Yaf_View_Interface initView ( void );
public Yaf_Dispatcher setView ( Yaf_View_Interface $view );
public Yaf_Dispatcher setDefaultModule ( string $default_module_name );
public Yaf_Dispatcher setDefaultController ( string $default_controller_name );
public Yaf_Dispatcher setDefaultAction ( string $default_action_name );
public Yaf_Dispatcher throwException ( boolean $switch = FALSE );
public Yaf_Dispatcher catchException ( boolean $switch = FALSE );
public Yaf_Response_Abstract dispatch ( Yaf_Request_Abstract $request );
} abstract Yaf_Response_Abstract {
protected array _body ;
protected array _header ;
public boolean setBody ( string $body ,string $name = NULL ); 如: $this->getResponse()->setBody("Hello World");要响应的字符串, 一般是一段HTML, 或者是一段JSON(返回给Ajax请求)
public boolean prependBody ( string $body ,string $name = NULL ); 往已有的响应body前插入新的内容,
public boolean appendBody ( string $body , string $name = NULL );往已有的响应body后附加新的内容
public boolean clearBody ( void );
public string getBody ( void ); 获取已经设置的响应body
public boolean response ( void );
public boolean setRedirect ( string $url );
public string __toString ( void );
}

yaf学习的更多相关文章

  1. yaf学习资料

    yaf学习资料 文档 鸟哥的官方文档 Yaf框架结合PHPUnit的集成测试 php yaf框架扩展实践六--单元测试.计划任务.第三方库等 php yaf框架扩展实践一--配置篇 yaf实战例子 y ...

  2. Lnmp上安装Yaf学习(一)

    今天学习Lnmp上面如何安装Yaf流程 一.安装Lnmp 集成环境 访问路径:https://lnmp.org/install.html 这里我安装稳定版lnmp 1)   wget -c http: ...

  3. Yaf学习(二)----Yaf初体验

    1.hello world 1.1 用yaf输出hello world 1.首先配置host,nginx 2.host不用多说,指向虚拟机IP即可 1.2 重点说一下nginx (只说server块) ...

  4. yaf学习之——生成yaf示例框架

    windows 下面的生成yaf示例框架 1,下载 https://github.com/laruence/yaf 2,解压以后得到yaf-master文件夹 3,cmd命令窗口cd到上面解压的文件夹 ...

  5. yaf学习之——yaf安装

    yaf的github源码地址 https://github.com/laruence/yaf 第一步: 下载dll扩展: http://pecl.php.net/package/yaf/2.3.5/w ...

  6. Lnmp上安装Yaf学习(二)

    上一节主要实践了在Lnmp上安装Yaf扩展,那么这一节将测试 Yaf 的一个简单demo的运行. 一.通过Lnmp 创建 vhost 文件 [root@localhost yaf-3.0.6]# ln ...

  7. Yaf学习(三)----Yaf类库Library和Model的命名规则

    1.Yaf的library和model的文件命名规则和调用 1.1在项目中,往往需要封装一些,如redis,不同的产品需要用不同的库等等等,这就涉及到封装 1.在 Yaf 中,我们可以写一个单例模式的 ...

  8. Yaf学习(一)----Linux安装Yaf

    1.简介 Yaf,全称 Yet Another Framework,是一个高性能的PHP开发框架,采用PHP扩展实现(c语言).Blablablabla....... 2.环境 2.1 虚拟机 虚拟机 ...

  9. yaf学习网站

    http://www.01happy.com/php-yaf-ext-business/

随机推荐

  1. Jsoup爬取带登录验证码的网站

    今天学完爬虫之后想的爬一下我们学校的教务系统,可是发现登录的时候有验证码.因此研究了Jsoup爬取带验证码的网站: 大体的思路是:(需要注意的是__VIEWSTATE一直变化,所以我们每个页面都需要重 ...

  2. 巅峰极客CTF writeup[上]

    经验教训 1.CTF不比实战,最好不要死磕.死磕就输了.我就是死磕在缓存文件死的.真的惭愧: 2.对于flag的位置不要太局限于web目录下,如果是命令执行直接上find / -name flag*: ...

  3. ProxySQL 排错 Max connect timeout reached while reaching hostgroup 10 after 10000ms

    ProxySQL 排错 问题分析: 在ProxySQL在集群下,因未知原因导致误测到所有节点OFFLINE_HARD,并runtime_mysql_servers表清空,从而导致前端查询无法传递到后端 ...

  4. ProxySQL 监控和统计

    ProxySQL 监控和统计 很多有价值的统计数据在stats和monitor库中. admin@127.0.0.1 [(none)]>SHOW TABLES FROM stats; +---- ...

  5. openjudge-NOI 2.6-2988 计算字符串距离

    题目链接:http://noi.openjudge.cn/ch0206/2988/ 题解: 首先,题目有误,少了一个添加操作 和求解LCS之类的思路类似 f[i][j]表示a序列中1..i的部分和b序 ...

  6. Hashtable之Properties

    properties的使用:1.Hashtable的实现类,线程安全.与HashMap不同,Hashtable不允许使用null作为key和value2.和HashMap一样,Hashtable也不能 ...

  7. python RSA加密解密及模拟登录cnblog

    1.公开密钥加密 又称非对称加密,需要一对密钥,一个是私人密钥,另一个则是公开密钥.公钥加密的只能私钥解密,用于加密客户上传数据.私钥加密的数据,公钥可以解密,主要用于数字签名.详细介绍可参见维基百科 ...

  8. Ubuntu 下查看已安装的软件

    Ubuntu 下如何查看已安装的软件 1.查看安装的所有软件 dpkg -l 例如: dpkg -l | grep ftp 2.查看软件安装的路径 dpkg -L | grep ftp 也可以用 wh ...

  9. WebService初识

    Web service 是一种跨编程语言和跨操作系统平台的远程调用技术,即跨平台远程调用技术.也就是说,不管是J2EE架构,还是.net架构 只要按照规范就可以进行通信,实现数据交互等. 这里说的&q ...

  10. 开始学习MaxCompute

    https://help.aliyun.com/document_detail/34615.html?spm=a2c4g.11186623.6.688.jVxTMW