gpt4 book ai didi

php - 我在哪里保存 Zend_Form 文件?

转载 作者:行者123 更新时间:2023-12-03 19:14:24 26 4
gpt4 key购买 nike

我正在尝试学习 Zend Framework!我对它很感兴趣,但我找不到一个教程说明它应该存储在 Zend_Form 类的位置!也许这是很简单的事情,但我还无法理解......我看过有关此的教程:

<?php
class Form_Example extends Zend_Form
{
public function init()
{
// Great code here
}
}

但是他们都没有说这段代码去哪了?????在目录树中哪个文件夹中的文件??我已经阅读并理解,并且我已经用模块、 Controller 、 Action 、布局做了一个小例子,我知道命名约定和文件夹结构的重要性。那么这个表单类必须去哪里,我该如何从 View 中调用它??

非常感谢,我知道对于已经知道如何很好地使用 Zend Framework 的人来说这一定很容易 =)

最佳答案

做到这一点的最佳方式是让采埃孚为您代劳。 ZF 附带了适用于 Windows 和 *nix 的命令行界面。

在命令行中,您可以键入 zf create form Example,然后 ZF 将在其默认应用程序级别位置创建一个名为 Example.php 的空表单。

通常这将位于 application/forms/Example.php 并且类名将是 Application_Form_Example

如果您需要在模块中构建表单,命令将类似:
zf create form Example -m admin
其中 -m 表示您希望在模块中创建文件,admin 是名称模块。

表单是 Zend Framework 中预定义的资源之一,因此具有默认位置。还有一些其他资源是预定义的并具有默认值。

The Module Resource Autoloader

Zend Framework ships with a concrete implementation of Zend_Loader_Autoloader_Resource that contains resource type mappings that cover the default recommended directory structure for Zend Framework MVC applications. This loader, Zend_Application_Module_Autoloader, comes with the following mappings:

    forms/          => Form
models/ => Model
models/DbTable/ => Model_DbTable
models/mappers/ => Model_Mapper
plugins/ => Plugin
services/ => Service views/
helpers => View_Helper
filters => View_Filter

As an example, if you have a module with the prefix of "Blog_", and attempted to instantiate the class "Blog_Form_Entry", it would look in the resource directory's "forms/" subdirectory for a file named "Entry.php". When using module bootstraps with Zend_Application, an instance of Zend_Application_Module_Autoloader will be created by default for each discrete module, allowing you to autoload module resources.

关于php - 我在哪里保存 Zend_Form 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12325912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com