Zend 似乎不想加载我创建的表单
嘿, 我似乎正在攀登一条非常可怕的学习曲线。我花了几个小时才达到可以构建/编写代码的程度。我最初希望能够在其各自的模块内存储表单或模型,例如: ./application/module/ModuleName/forms/ClassName.php 但是当我尝试使用以下方法实例化一个类时: $form = new ModuleName_Form_ClassName( );它失败了。因此,我想通过将其移动到默认模块来简化一切。但是它仍然不起作用。我还是做错了什么。我不知道是什么。
在我的控制器操作中,我有以下内容:
// some other code
$form = new Form_Login();
加载操作时,我收到此错误消息:
Fatal error: Class 'Form_Login' not found in /some folder/www/application/modules/default/controllers/AdministrationController.php on line 22
我的 application.ini 包含:
appnamespace = "SomeModule"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
表单存储在 ./application/modules/default/forms/Login.php
1 内。我该如何解决这个问题?我收到的错误消息几乎没有用。
2.我真的认为如果有某种方法可以调试 __autoload() 函数,我所有的问题都可能得到解决。不是吗?
3.难道没有办法使用默认模块内另一个模块的模型/表单吗?这就是我想做的。我认为这会让一切变得更加结构化。如果这是不可能的,我根本看不出这有什么用...
干杯,
一位生病的 Zend 开发新手。
Hey,
I seem to be climbing a pretty horrible learning curve. It's taking me hours to even get to the point where I can structure/write code. I originally wanted to be able to store a form or a model inside its respective module, for example: ./application/module/ModuleName/forms/ClassName.php but when I tried to instantiate a class with: $form = new ModuleName_Form_ClassName(); it failed. Therefore, I thought I would simplify everything by moving it to the default module. However it still isn't working. I'm still doing something wrong. I've no idea what.
Inside my controller action I have this:
// some other code
$form = new Form_Login();
On loading the action, I get this error message:
Fatal error: Class 'Form_Login' not found in /some folder/www/application/modules/default/controllers/AdministrationController.php on line 22
My application.ini contains:
appnamespace = "SomeModule"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] =
The form is stored inside ./application/modules/default/forms/Login.php
1. How can I troubleshoot this? The error message I am getting is next to useless.
2. I really think all of my problems might be solved if there was some way of debugging the __autoload() function. Is there not?
3. Can there not be a way of using models/forms from another Module inside the default module? That is what I wanted to do. I thought it would make everything more structured. If this isn't possible I just can't see how this would be useful at all...
Cheers,
An ailing newbie Zend developer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来你第一次就差点就拥有了。假设您的模块是用户,您的表单是登录。为了使
application/module/users/forms/Login.php
工作:Users_Form_Login
资源。在 application.ini 中使用 module[] =
来初始化模块资源(您拥有)。。
定义于
application/module/users/Bootstrap.php
。路径区分大小写。我同意自动加载器可能很难调试,不幸的是,它是要么有效要么无效的事情之一,但是一旦你设置了它,你就可以忘记它。希望以上内容能够回答您的第三个问题 - 是的,您可以使用默认模块内另一个模块中的表单。
Sounds like you almost had it the first time. Let's say your module is Users and your form Login. In order for
application/module/users/forms/Login.php
to work:Users_Form_Login
resources.modules[] =
in your application.ini to initialise the module resource (which you have).
defined at
application/module/users/Bootstrap.php
. The paths are case sensitive.I agree that the autoloader can be quite difficult to debug, unfortunately it's one of those things that either works or it doesn't, but once you have it setup you can forget about it. Hopefully the above will answer your third question - yes you can use forms from another module inside the default one.