大网数据广告活动
PHP 语言与运行手册

Yaf_Bootstrap_Abstract 类

· 52CE 我爱测

(No version information available, might only be in Git)

Yaf_Bootstrap_Abstract 类

(No version information available, might only be in Git)

简介

Bootstrap 是用来在 Application 运行(run)之前做一些初始化工作的机制。

可以通过继承 Yaf_Bootstrap_Abstract 来定义自己的 Bootstrap 类.

在 Bootstrap 类中所有以“_init”开头的公有的方法, 都会被按照定义顺序依次在 Yaf_Application::bootstrap() 被调用的时刻调用.

示例

示例 #1 Bootstrap 示例

<?php
   /* bootstrap class should be defined under ./application/Bootstrap.php */
   class Bootstrap extends Yaf_Bootstrap_Abstract {
        public function _initConfig(Yaf_Dispatcher $dispatcher) {
            var_dump(__METHOD__);
        }
        public function _initPlugin(Yaf_Dispatcher $dispatcher) {
            var_dump(__METHOD__);
        }
   }

   $config = array(
       "application" => array(
           "directory" => dirname(__FILE__) . "/application/",
       ),
   );
 
   $app = new Yaf_Application($config);
   $app->bootstrap();
?>

以上示例的输出类似于:

string(22) "Bootstrap::_initConfig"
string(22) "Bootstrap::_initPlugin"

类摘要

abstract class Yaf_Bootstrap_Abstract {
/* 属性 */
/* 方法 */
}

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。