MVC 如何在 Zend 框架中工作 [英] How mvc works in Zend framework

查看:38
本文介绍了MVC 如何在 Zend 框架中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢之前的回复..

我正在尝试使用 zend 框架打印 Hello_world.我在模型文件夹中编写了 php 文件,并将字符串值作为Hello_world"返回.在控制器中,我像这样访问 PHP 的值
$value = new TextReturner();$this->view->setValue = $value->hello_world(); .我不知道如何从控制器访问值到视图 php 文件.我是 Zend 框架的新手.我已经看过zend框架的大纲结构,我不知道如何通过编码访问.如果有人知道如何通过 MVC 打印 hello_world 请指导我.

I am trying to print Hello_world using zend framework. I wrote php file in model folder and return string value as a "Hello_world". In controller i access the value of PHP like this
$value = new TextReturner(); $this->view->setValue = $value->hello_world(); . i dont know how to access the value from controller to the view php file. I am new to zend framework. I already go through the outline structure of zend framework, i dont know how to access through codings. If anyone have idea of how to print hello_world through MVC pls guide me.

推荐答案

您正在尝试使用 class $value = new TextReturner();但您的控制器没有看到该类.

You are trying to use class $value = new TextReturner(); but your controller doesn't see that class.

在您的 Bootstrap 文件中设置它会有所帮助:

Set this in your Bootstrap file that will help:

protected function _initAutoLoad() {
    // Add autoloader empty namespace
    $autoLoader = Zend_Loader_Autoloader::getInstance();
    $resourceLoader = new Zend_Loader_Autoloader_Resource(
            array(
                'basePath'      => APPLICATION_PATH,
                'namespace'     => '',
                'resourceTypes' => array(
                'model'         => array(
                        'path'      => 'models/',
                        'namespace' => 'Model_'
                    ),
                ),
            )
    );
    return $resourceLoader;
}

这将自动加载您的所有模型类.

This will be autoload all of your model class.

这篇关于MVC 如何在 Zend 框架中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆