www.2527.com_澳门新葡8455手机版_新京葡娱乐场网址_
做最好的网站

Framework教程之模型Model基本准则和利用情势,Fr

2019-07-14 01:39 来源:未知

本文实例呈报了Zend Framework教程之模型Model基本准绳和接纳办法。分享给大家供大家参照他事他说加以考察,具体如下:

正文实例叙述了Zend Framework教程之Zend_Layout布局助手。分享给大家供大家参谋,具体如下:

正文实例陈诉了Zend Framework教程之模型Model用法。分享给大家供我们参考,具体如下:

此间讲讲Zend中的model。其实Zend中的Model管理是一定轻便的。

一、作用

附三个大致粗俗的例证。只是大略表达了用法:即使要搜求,能够本人追踪源码通晓。

那至关心尊敬要得益于autoload功效。不像其它框架,为model定义复杂的基类。

布局的职能和模版的功效类似。能够认为是把网址通用、公共的一对拿出来作为通用的页面框架。举例一个大旨的web页面,大概页面包车型地铁头和尾都是一律,分裂的也许只是内容body部分不雷同,能够把集体的有个别做成模版。不只能够增加支付功能,也为早先时期的掩护带来方便。

model_demo1

假定要定义model,不得不要持续一个model的基类,技能够使用具体的效能。

二、使用

│  .project
│  .buildpath
│  .zfproject.xml

├─.settings
│      org.eclipse.php.core.prefs
│      .jsdtscope
│      org.eclipse.wst.jsdt.ui.superType.name
│      org.eclipse.wst.jsdt.ui.superType.container

├─application
│  │  Bootstrap.php
│  │
│  ├─configs
│  │      application.ini
│  │
│  ├─controllers
│  │      IndexController.php
│  │      ErrorController.php
│  │
│  ├─models
│  │      Test.php
│  │      ModelTest.php
│  │
│  └─views
│      ├─scripts
│      │  ├─index
│      │  │      index.phtml
│      │  │
│      │  └─error
│      │          error.phtml
│      │
│      └─helpers
├─docs
│      README.txt

├─library
│  ├─app
│  │      Test.php
│  │
│  ├─myApp
│  │      Test.php
│  │
│  ├─Zend
│  │      Test.php
│  │
│  ├─AppTest
│  │      Test.php
│  │
│  └─AppTest2
│          Test.php

├─public
│      index.php
│      .htaccess

└─tests
    │  phpunit.xml
    │  bootstrap.php
    │
    ├─application
    │  └─controllers
    │          IndexControllerTest.php
    │
    └─library

Zend中并未对模型举行打包。

这里举二个粗略的事例。

正如是从上到下,每一个文本的源码,不再详细表达:

案由大概是Model首即使和实际业务逻辑相关的,实行过多的包装,只会弄巧成拙。

先是用zend studio创造一个主导的zend framework项目:layout_demo1

/model_demo1/application/configs/application.ini

Zend使用了autoload和namespace功用,很委婉的消除了这么些难点。

结构轮廓上如下“

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
autoloadernamespaces.app = "App_"
autoloadernamespaces.my = "MyApp_"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

创制三个zendframework项目model_demo1

├─.settings
├─application
│  ├─configs
│  ├─controllers
│  ├─models
│  └─views
│      ├─helpers
│      └─scripts
│          ├─error
│          └─index
├─docs
├─library
├─public
└─tests
    ├─application
    │  └─controllers
    └─library

/model_demo1/application/controllers/IndexController.php

为了便于查看错误大家能够在安排文件中/model_demo1/application/configs/application.ini展开错误音讯按钮如下:

1.加入layout功能:

<?php
class IndexController extends Zend_Controller_Action {
  public function init() {
    /* Initialize action controller here */
  }
  public function indexAction() {
    var_dump ( Application_Model_Test::getUserInfo () );
    App_Test::echoAppTest ();
    MyApp_Test::echoAMyAppTest ();
    Zend_Test::echoZendTest ();
    AppTest_Test::echoAppTestTest ();
    $auto_loader = Zend_Loader_Autoloader::getInstance();
    $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
        'basePath' => '/www/model_demo1/application',
        'namespace' => '',
        'resourceTypes' => array(
            'model' => array(
                'path' => 'models',
                'namespace' => 'Model'
            )
        )
    )
    );
    $auto_loader->pushAutoloader($resourceLoader);
    $auto_loader->registerNamespace(array('AppTest2_'));
    AppTest2_Test::echoAppTest2Test();
    Model_ModelTest::echoModelModelTest();
    exit ();
  }
}
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

采纳配置文件/layout_demo2/application/configs/application.ini,参预如下配置

/model_demo1/application/models/ModelTest.php

接下去大约的讲讲zend中的model:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
[staging : production]
<?php
class Model_ModelTest{
  static function echoModelModelTest(){
    echo 'Model_ModelTest<br/>';
  }
}

1.默认的Model

2.应和的目录和布局模版文件 /layout_demo2/application/layouts/scripts/layout.phtml

/model_demo1/application/models/Test.php

三个正经的webapp中会有application/models那样的目录。简单看出,models用来寄放你的app的model

├─application
│  ├─configs
│  ├─controllers
│  ├─layouts
│  │  └─scripts
│  ├─models
│  └─views

<?php
class Application_Model_Test {
  static public function getUserInfo() {
    return array (
        'user_name' => '张三',
        'user_gender' => '男'
    );
  }
}

以此目录的无敌之处在于,假如您在models目录中定义了切实的class。zend会自动的帮大家加载,当然要坚守一定的预订,前提是:

layout.html类似如下:

/model_demo1/application/Bootstrap.php

比方说,用zf命令行创设三个名叫Test的Model

<!doctype html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>my app</title>
  <body>
   <div id="header">
    header
   </div>
   <div id="content">
    <?php echo $this -> layout() -> content;?>
   </div>
   <div id="footer">
    header
   </div>
  </body>
</html>
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
  protected function _initAutoload() {
    $app = $this->getApplication ();
    $namespaces = array (
        'AppTest'
    );
    $app->setAutoloaderNamespaces ( $namespaces );
    return $app;
  }
}
zf create model Test

这里的

/model_demo1/library/app/Test.php

Creating a model at /www/model_demo1/application/models/Test.php

<?php echo $this -> layout() -> content;?>
<?php
class App_Test {
  static public function echoAppTest() {
    echo 'App_Test<br/>';
  }
}

Updating project profile '/www/model_demo1/.zfproject.xml'

是相比重要的。表示此处为布局的内容,也便是会动态变化的地点。

/model_demo1/library/AppTest/Test.php

刷新一下门类目录能够阅览,新添了之类文件/model_demo1/application/models/Test.php

如此那般,运行一下主次

<?php
class AppTest_Test{
  static public function echoAppTestTest(){
    echo 'AppTestTest<br/>';
  }
}

文本内容如下:

www.localzend.com/layout_demo1/public/

/model_demo1/library/AppTest2/Test.php

<?php
class Application_Model_Test
{}

浮动的html源码如下

<?php
class AppTest2_Test{
  static public function echoAppTest2Test(){
    echo 'AppTest2Test<br/>';
  }
}

轻松看出大家要运用Model要安分守己如下准绳:

<!doctype html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>my app</title>
  <body>
   <div id="header">
    header
   </div>
   <div id="content">
    <style>
 a:link,
 a:visited
 {
  color: #0398CA;
 }
 span#zf-name
 {
  color: #91BE3F;
 }
 div#welcome
 {
  color: #FFFFFF;
  background-image:url(http://framework.zend.com/images/bkg_header.jpg);
  width: 600px;
  height: 400px;
  border: 2px solid #444444;
  overflow: hidden;
  text-align: center;
 }
 div#more-information
 {
  background-image:url(http://framework.zend.com/images/bkg_body-bottom.gif);
  height: 100%;
 }
</style>
<div id="welcome">
 <h1>Welcome to the Zend Framework!</h1>
 <h3>This is your project's main page</h3>
 <div id="more-information">
  <p><img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" /></p>
  <p>
   Helpful Links: <br />
   <a href="http://framework.zend.com/">Zend Framework Website</a> |
   <a href="http://framework.zend.com/manual/en/">Zend Framework Manual</a>
  </p>
 </div>
</div>   </div>
   <div id="footer">
    header
   </div>
  </body>
</html>

/model_demo1/library/myApp/Test.php

1).以Application_Model_早先,然后后边是自定义的model的类名称。

中等部分正是/layout_demo1/application/views/scripts/index/index.phtml的内容。

<?php
class MyApp_Test {
  static public function echoAMyAppTest() {
    echo 'MyApp_Test<br/>';
  }
}

即:大家web应用的model的目录结构为/model_demo1/application/models/Test.php

流入:能够通过zf的一声令下工具自动生成layout的布署和文书。

/model_demo1/library/Zend/Test.php

对应的命名空间为Application_Model_Test。

指令如下:

<?php
class Zend_Test{
  static public function echoZendTest(){
    echo 'ZendTest<br/>';
  }
}

application对应Application

zf enable layout

尚未贴出的代码,是创造项目暗中认可的代码。

models对应models

能够参谋命令行章节

切记:遵守约定准绳,就可以幸免不须要的劳苦。

Test是model的类公事的称谓。

三、配置

越来越多关于zend相关内容感兴趣的读者可查阅本站专项论题:《Zend FrameWork框架入门教程》、《php优良开荒框架总计》、《Yii框架入门及常用本事计算》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php mysql数据库操作入门教程》及《php常见数据库操作技能汇总》

类的称谓遵照约束就是:class Application_Model_Test {

1.自定义存放地方和称号能够经过application.ini配置文件配置布局文件的贮存地方以及布局文件的称谓,比方:

可望本文所述对大家PHP程序设计有着支持。

也简单精通Application_Model_,那样的法则遵从zend framework的autoload和namespace的预约。

resources.layout.layoutPath = APPLICATION_PATH "/mylayouts/scripts"
resources.layout.layout = "mylayout"

你大概感兴趣的小说:

  • 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_Request实例详解
  • Zend Framework教程之动作的基类Zend_Controller_Action详解
  • Zend Framework教程之分发器Zend_Controller_Dispatcher用法详解
  • Zend Framework教程此前端调节器Zend_Controller_Front用法详解
  • Zend Framework教程之视图组件Zend_View用法详解
  • Zend Framework教程之Autoloading用法详解

2).Application命名空间

2.在action中使用layout对象

实则Application也是大家在布署文件中配置的选拔的命名空间。

能够经过

假设把计划文件的appnamespace = "Application"修改为appnamespace = "App"。

$layout = $this->_helper->layout();

咱俩原先的顺序,就能够报错了。原因分明。所以zend也平素不那么智能。

或者

一旦要详细追究其原理,大致是之类的类成就这些效果的:

$helper = $this->_helper->getHelper('Layout');
$layout = $helper->getLayoutInstance();
Zend_Application_Bootstrap_Bootstrap
Zend_Application_Module_Autoloader

获取布局对象。

2.自定义命名空间

能够透过如下情势禁止使用当前action使用布局形式

Zend是暗中同意的命名空间。比如在/model_demo1/library/Zend/Test.php创建类Zend_Test

$layout->disableLayout();
<?php
class Zend_Test{
 static public function echoZendTest(){
  echo 'ZendTest<br/>';
 }
}

能够由此

无需做其余操作,就可以在程序中动用。举个例子:Zend_Test::echoZendTest();
此间大约表明自定义命名空间的二种艺术:

$layout->setLayout('other');

1).使用application.ini配置文件

来设置使用另壹个布局文件

暗许命名空间

能够经过来传递赋值

appnamespace = "Application"
$layout->assign('headertitle', 'app title');
$layout->somekey = "value"

自定义命名空间

3.其余获取layout对象的主意

autoloadernamespaces.app = "App_"
autoloadernamespaces.my = "MyApp_"

(1)

或者

$layout = Zend_Layout::getMvcInstance();
autoloadernamespaces[] = "App_"
autoloadernamespaces[] = "MyApp_"

(2)

切实达成类为:ZendApplication.php

$layout = $bootstrap->getResource('Layout');
public function setOptions(array $options)
{
 if (!empty($options['config'])) {
  if (is_array($options['config'])) {
   $_options = array();
   foreach ($options['config'] as $tmp) {
    $_options = $this->mergeOptions($_options, $this->_loadConfig($tmp));
   }
   $options = $this->mergeOptions($_options, $options);
  } else {
   $options = $this->mergeOptions($this->_loadConfig($options['config']), $options);
  }
 }
 $this->_options = $options;
 $options = array_change_key_case($options, CASE_LOWER);
 $this->_optionKeys = array_keys($options);
 if (!empty($options['phpsettings'])) {
  $this->setPhpSettings($options['phpsettings']);
 }
 if (!empty($options['includepaths'])) {
  $this->setIncludePaths($options['includepaths']);
 }
 if (!empty($options['autoloadernamespaces'])) {
  $this->setAutoloaderNamespaces($options['autoloadernamespaces']);
 }

四、其余用法,完成原理

2).在Bootstrap.php文件中

现实其余的施用格局可以参谋

例如/model_demo1/application/Bootstrap.php

Zend_Layout_Controller_Action_Helper_Layout类,
Zend_Layout_Controller_Plugin_Layout类
Zend_View_Helper_Layout类
可想而知。

<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
 protected function _initAutoload() {
  $app = $this->getApplication ();
  $namespaces = array (
    'AppTest'
  );
  $app->setAutoloaderNamespaces ( $namespaces );
  return $app;
 }
}
<?php
/** Zend_Controller_Action_Helper_Abstract */
require_once 'Zend/Controller/Action/Helper/Abstract.php';
/**
 * Helper for interacting with Zend_Layout objects
 *
 * @uses  Zend_Controller_Action_Helper_Abstract
 * @category Zend
 * @package Zend_Controller
 * @subpackage Zend_Controller_Action
 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license http://framework.zend.com/license/new-bsd  New BSD License
 */
class Zend_Layout_Controller_Action_Helper_Layout extends Zend_Controller_Action_Helper_Abstract
{
 /**
  * @var Zend_Controller_Front
  */
 protected $_frontController;
 /**
  * @var Zend_Layout
  */
 protected $_layout;
 /**
  * @var bool
  */
 protected $_isActionControllerSuccessful = false;
 /**
  * Constructor
  *
  * @param Zend_Layout $layout
  * @return void
  */
 public function __construct(Zend_Layout $layout = null)
 {
  if (null !== $layout) {
   $this->setLayoutInstance($layout);
  } else {
   /**
    * @see Zend_Layout
    */
   require_once 'Zend/Layout.php';
   $layout = Zend_Layout::getMvcInstance();
  }
  if (null !== $layout) {
   $pluginClass = $layout->getPluginClass();
   $front = $this->getFrontController();
   if ($front->hasPlugin($pluginClass)) {
    $plugin = $front->getPlugin($pluginClass);
    $plugin->setLayoutActionHelper($this);
   }
  }
 }
 public function init()
 {
  $this->_isActionControllerSuccessful = false;
 }
 /**
  * Get front controller instance
  *
  * @return Zend_Controller_Front
  */
 public function getFrontController()
 {
  if (null === $this->_frontController) {
   /**
    * @see Zend_Controller_Front
    */
   require_once 'Zend/Controller/Front.php';
   $this->_frontController = Zend_Controller_Front::getInstance();
  }
  return $this->_frontController;
 }
 /**
  * Get layout object
  *
  * @return Zend_Layout
  */
 public function getLayoutInstance()
 {
  if (null === $this->_layout) {
   /**
    * @see Zend_Layout
    */
   require_once 'Zend/Layout.php';
   if (null === ($this->_layout = Zend_Layout::getMvcInstance())) {
    $this->_layout = new Zend_Layout();
   }
  }
  return $this->_layout;
 }
 /**
  * Set layout object
  *
  * @param Zend_Layout $layout
  * @return Zend_Layout_Controller_Action_Helper_Layout
  */
 public function setLayoutInstance(Zend_Layout $layout)
 {
  $this->_layout = $layout;
  return $this;
 }
 /**
  * Mark Action Controller (according to this plugin) as Running successfully
  *
  * @return Zend_Layout_Controller_Action_Helper_Layout
  */
 public function postDispatch()
 {
  $this->_isActionControllerSuccessful = true;
  return $this;
 }
 /**
  * Did the previous action successfully complete?
  *
  * @return bool
  */
 public function isActionControllerSuccessful()
 {
  return $this->_isActionControllerSuccessful;
 }
 /**
  * Strategy pattern; call object as method
  *
  * Returns layout object
  *
  * @return Zend_Layout
  */
 public function direct()
 {
  return $this->getLayoutInstance();
 }
 /**
  * Proxy method calls to layout object
  *
  * @param string $method
  * @param array $args
  * @return mixed
  */
 public function __call($method, $args)
 {
  $layout = $this->getLayoutInstance();
  if (method_exists($layout, $method)) {
   return call_user_func_array(array($layout, $method), $args);
  }
  require_once 'Zend/Layout/Exception.php';
  throw new Zend_Layout_Exception(sprintf("Invalid method '%s' called on layout action helper", $method));
 }
}



<?php
/** Zend_Controller_Plugin_Abstract */
require_once 'Zend/Controller/Plugin/Abstract.php';
/**
 * Render layouts
 *
 * @uses  Zend_Controller_Plugin_Abstract
 * @category Zend
 * @package Zend_Controller
 * @subpackage Plugins
 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license http://framework.zend.com/license/new-bsd  New BSD License
 * @version $Id: Layout.php 23775 2011-03-01 17:25:24Z ralph $
 */
class Zend_Layout_Controller_Plugin_Layout extends Zend_Controller_Plugin_Abstract
{
 protected $_layoutActionHelper = null;
 /**
  * @var Zend_Layout
  */
 protected $_layout;
 /**
  * Constructor
  *
  * @param Zend_Layout $layout
  * @return void
  */
 public function __construct(Zend_Layout $layout = null)
 {
  if (null !== $layout) {
   $this->setLayout($layout);
  }
 }
 /**
  * Retrieve layout object
  *
  * @return Zend_Layout
  */
 public function getLayout()
 {
  return $this->_layout;
 }
 /**
  * Set layout object
  *
  * @param Zend_Layout $layout
  * @return Zend_Layout_Controller_Plugin_Layout
  */
 public function setLayout(Zend_Layout $layout)
 {
  $this->_layout = $layout;
  return $this;
 }
 /**
  * Set layout action helper
  *
  * @param Zend_Layout_Controller_Action_Helper_Layout $layoutActionHelper
  * @return Zend_Layout_Controller_Plugin_Layout
  */
 public function setLayoutActionHelper(Zend_Layout_Controller_Action_Helper_Layout $layoutActionHelper)
 {
  $this->_layoutActionHelper = $layoutActionHelper;
  return $this;
 }
 /**
  * Retrieve layout action helper
  *
  * @return Zend_Layout_Controller_Action_Helper_Layout
  */
 public function getLayoutActionHelper()
 {
  return $this->_layoutActionHelper;
 }
 /**
  * postDispatch() plugin hook -- render layout
  *
  * @param Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
  $layout = $this->getLayout();
  $helper = $this->getLayoutActionHelper();
  // Return early if forward detected
  if (!$request->isDispatched()
   || $this->getResponse()->isRedirect()
   || ($layout->getMvcSuccessfulActionOnly()
    && (!empty($helper) && !$helper->isActionControllerSuccessful())))
  {
   return;
  }
  // Return early if layout has been disabled
  if (!$layout->isEnabled()) {
   return;
  }
  $response = $this->getResponse();
  $content = $response->getBody(true);
  $contentKey = $layout->getContentKey();
  if (isset($content['default'])) {
   $content[$contentKey] = $content['default'];
  }
  if ('default' != $contentKey) {
   unset($content['default']);
  }
  $layout->assign($content);
  $fullContent = null;
  $obStartLevel = ob_get_level();
  try {
   $fullContent = $layout->render();
   $response->setBody($fullContent);
  } catch (Exception $e) {
   while (ob_get_level() > $obStartLevel) {
    $fullContent .= ob_get_clean();
   }
   $request->setParam('layoutFullContent', $fullContent);
   $request->setParam('layoutContent', $layout->content);
   $response->setBody(null);
   throw $e;
  }
 }
}



<?php
/** Zend_View_Helper_Abstract.php */
require_once 'Zend/View/Helper/Abstract.php';
/**
 * View helper for retrieving layout object
 *
 * @package Zend_View
 * @subpackage Helper
 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license http://framework.zend.com/license/new-bsd  New BSD License
 */
class Zend_View_Helper_Layout extends Zend_View_Helper_Abstract
{
 /** @var Zend_Layout */
 protected $_layout;
 /**
  * Get layout object
  *
  * @return Zend_Layout
  */
 public function getLayout()
 {
  if (null === $this->_layout) {
   require_once 'Zend/Layout.php';
   $this->_layout = Zend_Layout::getMvcInstance();
   if (null === $this->_layout) {
    // Implicitly creates layout object
    $this->_layout = new Zend_Layout();
   }
  }
  return $this->_layout;
 }
 /**
  * Set layout object
  *
  * @param Zend_Layout $layout
  * @return Zend_Layout_Controller_Action_Helper_Layout
  */
 public function setLayout(Zend_Layout $layout)
 {
  $this->_layout = $layout;
  return $this;
 }
 /**
  * Return layout object
  *
  * Usage: $this->layout()->setLayout('alternate');
  *
  * @return Zend_Layout
  */
 public function layout()
 {
  return $this->getLayout();
 }
}

/model_demo1/library/AppTest/Test.php

越多关于zend相关内容感兴趣的读者可查看本站专项论题:《Zend FrameWork框架入门教程》、《php突出开垦框架计算》、《Yii框架入门及常用能力总计》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php mysql数据库操作入门教程》及《php常见数据库操作手艺汇总》

<?php
class AppTest_Test{
 static public function echoAppTestTest(){
  echo 'AppTestTest<br/>';
 }
}

指望本文所述对我们PHP程序设计有着协理。

/model_demo1/application/controllers/IndexController.php

您也许感兴趣的篇章:

  • zend Framework中的Layout(模块化得布局)详解
  • zend framework多模块多布局配置
  • Zend Framework连接Mysql数据库实例剖析
  • Zend Framework smarty用法实例详解
  • Zend Framework教程之Application用法实例详解
  • Zend Framework自定义Helper类相关切意事项总计
  • Zend Framework教程之Bootstrap类用法概述
  • Zend Framework教程之能源(Resources)用法实例详解
  • Zend Framework教程之Application和Bootstrap用法详解
  • Zend Framework教程之配备文件application.ini分析
  • Zend Framework教程之Loader以及PluginLoader用法详解
  • Zend Framework教程之Autoloading用法详解
  • Zend Framework基本页面布局分析
AppTest_Test::echoAppTestTest();

3).使用具体的类成就机关加载

$auto_loader = Zend_Loader_Autoloader::getInstance();
$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
  'basePath' => '/www/model_demo1/application',
  'namespace' => '',
  'resourceTypes' => array(
    'model' => array(
      'path' => 'models',
      'namespace' => 'Model'
    )
  )
)
);
$auto_loader->pushAutoloader($resourceLoader);
$auto_loader->registerNamespace(array('AppTest2_'));
AppTest2_Test::echoAppTest2Test();
Model_ModelTest::echoModelModelTest();

/model_demo1/application/models/ModelTest.php

<?php
class Model_ModelTest{
 static function echoModelModelTest(){
  echo 'Model_ModelTest<br/>';
 }
}

/model_demo1/library/AppTest2/Test.php

<?php
class AppTest2_Test{
 static public function echoAppTest2Test(){
  echo 'AppTest2Test<br/>';
 }
}

越来越多关于zend相关内容感兴趣的读者可查看本站专项论题:《Zend FrameWork框架入门教程》、《php杰出开荒框架总计》、《Yii框架入门及常用手艺总括》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

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

您只怕感兴趣的稿子:

  • WINDOWS WAMP Zend Framework 配置步骤分享
  • zend framework配置操作数据库实例深入分析
  • Zend framework管理多个http央求的流程剖判
  • 充足好用的Zend Framework分页类
  • 深入分析zend Framework如何自动加载类
  • Zend Framework页面缓存实例
  • Zend Framework 2.0事变管理器(The 伊芙ntManager)入门教程
  • Zend Framework开垦入门精彩教程
  • Zend Framework smarty用法实例详解
  • Zend Framework教程之视图组件Zend_View用法详解
  • Zend Framework动作助手Url用法详解
  • zend framework重定向方法小结
TAG标签:
版权声明:本文由澳门新葡8455手机版发布于计算机编程,转载请注明出处:Framework教程之模型Model基本准则和利用情势,Fr