Table of Contents
Zend Framework教程之Bootstrap类用法概述,zendbootstrap
您可能感兴趣的文章:
Home php教程 php手册 Zend Framework教程之Bootstrap类用法概述,zendbootstrap

Zend Framework教程之Bootstrap类用法概述,zendbootstrap

Jun 13, 2016 am 08:44 AM
bootstrap framework zend

Zend Framework教程之Bootstrap类用法概述,zendbootstrap

本文实例讲述了Zend Framework中Bootstrap类用法。分享给大家供大家参考,具体如下:

Zend_Application_Bootstrap_Bootstrapper

Zend_Application_Bootstrap_Bootstrapper是所有引导类必须实现的基本接口。基本功能是用于配置,注册资源,引导(无论是单个资源或整个应用程序),并运行应用程序。

接口方法:

Zend_Application_Bootstrap_Bootstrapper Interface

Method Return Value Parameters Description
__construct(
$application
)
Void
  • $application: 必填的。 

    接受一个Zend_Application

    或一个Zend_Application_Bootstrap_Bootstrapper对象作为唯一的参数。

构造方法。接受一个参数,参数要求是一个Zend_Application对象,或另一个引导对象。

setOptions(
array $options)
Zend_Application_Bootstrap_Bootstrapper
  • $options必填. 配置选项数组

通常情况下, 选项都可以匹配映射到对应的setter;否则,选项仅仅会被存储,便于以后查找

getApplication() Zend_Application |Zend_Application_Bootstrap_Bootstrapper N/A

获取application实例

getEnvironment() String N/A

获取environment

getClassResources() Array N/A

获取可以可用的资源

bootstrap($resource = null) Mixed
  • $resource可选.

如果 $resource为空,注册所有资源.如果为字符串注册指定的资源;如果是数组, 只注册指定的资源.

run() Void N/A

执行引导.


Zend_Application_Bootstrap_ResourceBootstrapper

Zend_Application_Bootstrap_ResourceBootstrapper是一个接口,用于引导类加载注册外部资源 。 也就是说,一个或多个资源不会直接在类中定义,而是通过插件形式引入。它应该与Zend_Application_Bootstrap_Bootstrapper结合使用; Zend_Application_Bootstrap_BootstrapAbstract实现了这个功能。

接口方法:

Zend_Application_Bootstrap_ResourceBootstrapper Interface

Method Return Value Parameters Description
registerPluginResource($resource, $options = null) Zend_Application_Bootstrap_ResourceBootstrapper
  • $resource: 必填,要求是资源名称。

    或者Zend_Application_Resource_Resource对象

  • $options可选. 数组或Zend_Config对象,传递要注册的资源的实例。

用于注册资源类,通过可选选项传递资源

unregisterPluginResource($resource) Zend_Application_Bootstrap_ResourceBootstrapper
  • $resource: 必填的。注销注册资源的名称

删除插件资源

hasPluginResource($resource) Boolean
  • $resource必填. 资源名称.


getPluginResource($resource) Zend_Application_Resource_Resource
  • $resource必填. 资源名称


getPluginResourceNames() Array N/A


setPluginLoader(Zend_Loader_PluginLoader_Interface $loader) Zend_Application_Bootstrap_ResourceBootstrapper
  • $loader必填


getPluginLoader() Zend_Loader_PluginLoader_Interface N/A



Zend_Application_Bootstrap_BootstrapAbstract

Zend_Application_Bootstrap_BootstrapAbstract是一个抽象类,它提供了一个通用的引导基本功能。它实现了Zend_Application_Bootstrap_Bootstrapper和Zend_Application_Bootstrap_ResourceBootstrapper。

Zend_Application_Bootstrap_BootstrapAbstract Methods

Method Return Value Parameters Description
__construct($application) Void
  • $application必填

Accepts either a Zend_Application or a Zend_Application_Bootstrap_Bootstrapper object as the sole argument.

setOptions(array $options) Zend_Application_Bootstrap_Bootstrapper
  • $options必填. 选项数组

所有选项都可以映射到选项指定的setter​​,

否则,该选项将只是被存储供以后查找

例如,如果在扩展类中定义一个setFoo() 方法,可以通过foo选项传递值


也可用于两个额外的,特殊的选项。
 pluginPaths用于指定资源插件路径前缀,它应该是一个前缀为文件系统路径的类的关联数组。
resources用于指定资源插件,并应包括插件资源实例的配置选项。

getOptions() Array N/A

 

hasOption($key) Boolean
  • $key必填.  .

 

getOption($key) Mixed
  • $key必填

不存在返回 NULL  

setApplication(Zend_Application | Zend_Application_Bootstrap_Bootstrapper $application) Zend_Application_Bootstrap_BootstrapAbstract
  • $application必填.

 

getApplication() Zend_Application |Zend_Application_Bootstrap_Bootstrapper N/A

 

getEnvironment() String N/A

 

getClassResources() Array N/A

 

getContainer() Object N/A

获取存储资源的容器。如果没有容器,可以通过Zend_Registry注册,然后返回一个Zend_Registry实例。

setContainer($container) Zend_Application_Bootstrap_BootstrapAbstract
  • $container,必填. 存放资源对象的容器对象


hasResource($name) Boolean
  • $name必填. 资源名称

 

getResource($name) Mixed
  • $name必填. 资源名称

 

bootstrap($resource = null) Mixed
  • $resource可选.

如果 $resource为空,注册所有资源.如果为字符串注册指定的资源;如果是数组, 只注册指定的资源.

run() Void N/A


__call($method, $args) Mixed
  • $method必填. 方法名.

  • $args必填. 方法参数数组.

为了方便可以用'bootstrap()'代替 bootstrap() 引导注册资源。


Zend_Application_Bootstrap_Bootstrap

Zend_Application_Bootstrap_Bootstrap是Zend_Application_Bootstrap_BootstrapAbstract具体实现。它的主要功能是,注册资源,然后运行 run() 方法。

在大多数情况下,你可以根据自己的引导需求继承这个类或直接使用这个类,并来注册资源插件。

启用 Application 自动加载功能

此外,该引导的实现提供了自动加载指定“命名空间”或指定资源类的前缀的功能

本质上,它实例化一个Zend_Application_Module_Autoloader的对象,参数为命名空间和引导类的目录。可以开启这个功能,通过 “appnamespace”配置选项设置命名空间。

As an INI example:

appnamespace = "Application"

Copy after login

Or in XML:

<appnamespace>Application</appnamespace>

Copy after login

默认情况下,Zend_Tool提供“Application”命名空间。

或者,可以在bootstrap类中通过$_appNamespace属性指定命名空间。

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
   protected $_appNamespace = 'Application';
}

Copy after login

更多关于zend相关内容感兴趣的读者可查看本站专题:《Zend FrameWork框架入门教程》、《php优秀开发框架总结》、《Yii框架入门及常用技巧总结》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

您可能感兴趣的文章:

  • Zend Framework自定义Helper类相关注意事项总结
  • Zend Framework教程之资源(Resources)用法实例详解
  • Zend Framework教程之Application和Bootstrap用法详解
  • Zend Framework教程之配置文件application.ini解析
  • Zend Framework教程之Loader以及PluginLoader用法详解
  • Zend Framework教程之Autoloading用法详解
  • Zend Framework教程之Resource Autoloading用法实例
  • Zend Framework教程之MVC框架的Controller用法分析
  • Zend Framework教程之路由功能Zend_Controller_Router详解
  • Zend Framework教程之Zend_Controller_Plugin插件用法详解
  • Zend Framework教程之响应对象的封装Zend_Controller_Response实例详解
  • Zend Framework教程之动作的基类Zend_Controller_Action详解
  • Zend Framework教程之前端控制器Zend_Controller_Front用法详解
  • Zend Framework教程之Application用法实例详解
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get the bootstrap search bar How to get the bootstrap search bar Apr 07, 2025 pm 03:33 PM

How to use Bootstrap to get the value of the search bar: Determines the ID or name of the search bar. Use JavaScript to get DOM elements. Gets the value of the element. Perform the required actions.

How to do vertical centering of bootstrap How to do vertical centering of bootstrap Apr 07, 2025 pm 03:21 PM

Use Bootstrap to implement vertical centering: flexbox method: Use the d-flex, justify-content-center, and align-items-center classes to place elements in the flexbox container. align-items-center class method: For browsers that do not support flexbox, use the align-items-center class, provided that the parent element has a defined height.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to view the date of bootstrap How to view the date of bootstrap Apr 07, 2025 pm 03:03 PM

Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.

See all articles