略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Yaf_Bootstrap_Abstract

2024-03-27

The Yaf_Bootstrap_Abstract class

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

简介

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

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

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

范例

示例 #1 Bootstrap example

<?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 {
/* 属性 */
/* 方法 */
}
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/class.yaf-bootstrap-abstract.php

冷却塔厂家 广告
-- 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3